Jump to content

multiple DB query


dflow

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.