Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: switching databases on the fly
11-01-2008, 05:37 PM #1
- Join Date
- Dec 2006
- Thanked 1 Time in 1 Post
switching databases on the fly
I am using database 1 to insert user content. One of the table indexes for database 1 that holds the user content is the userid.
I then need to get the username and other user information which is stored in a different table in database 2. The user account table in database 2 also uses the userid as its index.
How can I access user information from table "users" in database 2 to if I am using the userid from table "user_content" in database 1?
SELECT username FROM database2_users WHERE userid = database1_user_content_userid
I realize the above is totally wrong.. but it summarize what I am trying to do.
Also, I assume I have to open a connection to both databases, right?
11-01-2008, 05:43 PM #2
- Join Date
- Dec 2004
- In a place far, far away...
- Thanked 1,043 Times in 1,019 Posts
You will have to populate the somenumber part.PHP Code:
SELECT username FROM database2.tableindatabase2name WHERE database2.tableindatabase2.userid = somenumber
Why are you using two databases anyways rather than just two tables?
Users who have thanked _Aerospace_Eng_ for this post: