0

Are these 2 equivalent, if not how can I make them. I'm using php/Mysql (I'll use mysqli later)

mysql_select_db("db_App", $link);

$result = mysql_query("SELECT * FROM AppOne");

OR

$result = mysql_query("SELECT * FROM db_App.AppOne"); // how can I get this to work like above?
1
  • 4
    I really wouldn't use the mysql_* functions if I were you, they're not being maintained anymore, are intended for old versions of MySQL and are deprecated in all but name. You should switch to a more modern database layer such as mysqli or PDO Commented Jul 11, 2012 at 8:59

2 Answers 2

2

You'll always have to select a database. From then on, specifying the database in the query is useless. It's better not to specify it there anyway, as that'd make you run into troubles if your database changes at some point.

Sign up to request clarification or add additional context in comments.

3 Comments

Well then how do I use join, that requires 2 different databases?
no, it works fine whitout selecting a database, as long as you specify the databse in each query
Joining is usually done on tables in the same database, so specifying is redundant. If you're trying to join tables in multiple databases, reconsider your database model.
1

if you skip the $link in mysql_select_db("db_App", $link); they should do the same.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.