Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    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?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    PHP Code:
    SELECT username FROM database2.tableindatabase2name WHERE database2.tableindatabase2.userid somenumber 
    You will have to populate the somenumber part.

    Why are you using two databases anyways rather than just two tables?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    oesxyl (11-07-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •