Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How can i make this code work.

sanihappysanihappy Member Posts: 18
I want to select some records based on some conditions liking matching with a field in another table which is in another database...

help me in this...the table user is in database db2...

SELECT * FROM testcase_testengineer WHERE relid=9 and pass=177 and TestEngineer=(select user_id from db2.user where location=1)

Comments

  • SouldrinkerSouldrinker Member Posts: 143
    : I want to select some records based on some conditions liking matching with a field in another table which is in another database...
    :
    : help me in this...the table user is in database db2...
    :
    : SELECT * FROM testcase_testengineer WHERE relid=9 and pass=177 and TestEngineer=(select user_id from db2.user where location=1)
    :

    You need a field, that's in both of the tables, so I guess you have a user id, in both tables, to compare entrys. A query could look like the following.

    [code]
    SELECT db1.testcase_testengineer.*,
    db2.user.location
    FROM db1.testcase_testengineer
    LEFT JOIN db2.user ON db2.user.userid = db1.testcase_testengineer.userid
    WHERE db1.testcase_testengineerrelid = 9 AND db1.testcase_testengineerpass=177
    AND db2.location = 1
    [/code]

    I guess this would work fine ;)
Sign In or Register to comment.