If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Quering 2 IDs from a single table
Hi,
I need to query 2 salesman_ID from a table but I cannot figure out how. SELECT salesman_ID, FROM product WHERE salesman_ID=23 AND salesman_ID=18 and SELECT A.salesman_ID FROM product A INNER JOIN product B ON A.product_ID = B.product_ID AND A.salesman_ID = 19 AND B.salesman_ID = 23 Don't work. What am I missing. TIA Paul |
#2
|
|||
|
|||
Quering 2 IDs from a single table
What you've got is looking for all those records where salesman_ID is equal
to 23 and salesman_ID is equal to 18. Since a field can only have a single value, there will never be any rows that have both values. You want OR instead of AND: SELECT salesman_ID FROM product WHERE salesman_ID=23 OR salesman_ID=18 or, alternatively, SELECT salesman_ID FROM product WHERE salesman_ID IN (23,18) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Paul" wrote in message ... Hi, I need to query 2 salesman_ID from a table but I cannot figure out how. SELECT salesman_ID, FROM product WHERE salesman_ID=23 AND salesman_ID=18 and SELECT A.salesman_ID FROM product A INNER JOIN product B ON A.product_ID = B.product_ID AND A.salesman_ID = 19 AND B.salesman_ID = 23 Don't work. What am I missing. TIA Paul |
#3
|
|||
|
|||
Quering 2 IDs from a single table
Thank you. I noticed UNION also worked but I like your suggestion better.
"Douglas J. Steele" escribió en el mensaje ... What you've got is looking for all those records where salesman_ID is equal to 23 and salesman_ID is equal to 18. Since a field can only have a single value, there will never be any rows that have both values. You want OR instead of AND: SELECT salesman_ID FROM product WHERE salesman_ID=23 OR salesman_ID=18 or, alternatively, SELECT salesman_ID FROM product WHERE salesman_ID IN (23,18) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Paul" wrote in message ... Hi, I need to query 2 salesman_ID from a table but I cannot figure out how. SELECT salesman_ID, FROM product WHERE salesman_ID=23 AND salesman_ID=18 and SELECT A.salesman_ID FROM product A INNER JOIN product B ON A.product_ID = B.product_ID AND A.salesman_ID = 19 AND B.salesman_ID = 23 Don't work. What am I missing. TIA Paul |
Thread Tools | |
Display Modes | |
|
|