JOIN Query
I am need to lookup the email address or login in table A along with
it's corresponding userid in the same table. I then need to take that
userid, and search for it in table B. Since I am searching for a
number of email addresses, I was trying to use IN to create a group.
My original query looked like this:
SELECT tableA.mail, tableA.login, tableA.userid, tableB.firmname,
tableB.address, tableB.phone, tableB.userid FROM `tableA`,`tableB`
WHERE tableA.mail IN (`email1@email.com`, `email2@email.com`,
`email3@email.com`) OR tableA.login IN (`email1@email.com`,
`email2@email.com`, `email3@email.com`)
Then I tried a JOIN version:
SELECT `userid`, tableB.firmname, `tableB.address`, `tableB.phone`,
FROM `tableA` JOIN `tableB` ON (tableB.userid=tableA.userid) WHERE
tableB.userid=tableA.userid)
I just need to be able to find the userid of an email address in table
A and then lookup that userid in table B. Your help is appreciated.
|