dflow Posted March 24, 2011 Share Posted March 24, 2011 these DB are on the same server sp inter query how do i combine the mysql_db()? SELECT * FROM `sp.bookings` LEFT JOIN sp.bookings_items ON sp.bookings.id_item = sp.bookings_items.id LEFT JOIN inter.apartments ON inter.apartments.ID = sp.bookings_items.id_ref_external WHERE sp.bookings.the_date BETWEEN '$from_date' and '$to_date' and id_state=1 LIMIT 0 , 30 Quote Link to comment https://forums.phpfreaks.com/topic/231607-multiple-db-query/ Share on other sites More sharing options...
DavidAM Posted March 24, 2011 Share Posted March 24, 2011 That query looks like it would work (as long as the username used to login has the correct permissions in each db). Did you try it? Are you asking what value you would supply for mysql_select_db()? This function sets the default database that is used if you don't specify a database in the query. Since your query is qualifying each table with the db name, it should not matter what db you specify to mysql_select_db(). I would use the one that most of my queries will be accessing. You could leave the call out completely. Then any query you submit without qualifying the tablename with the database name will produce an error about not having a default db; which would remind you to add the call in with the appropriate database. Note: I have not tested to verify the part about leaving it out. It's pretty much a guess based on my understanding of the purpose of that function. Quote Link to comment https://forums.phpfreaks.com/topic/231607-multiple-db-query/#findComment-1191790 Share on other sites More sharing options...
dflow Posted April 4, 2011 Author Share Posted April 4, 2011 gr8 ill test it cheers Quote Link to comment https://forums.phpfreaks.com/topic/231607-multiple-db-query/#findComment-1196595 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.