Quering 2 IDs from a single table

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

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
 
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)
 
Back
Top