A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Quering 2 IDs from a single table



 
 
Thread Tools Display Modes
  #1  
Old May 30th, 2004, 05:42 PM
Paul
external usenet poster
 
Posts: n/a
Default 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  
Old May 30th, 2004, 06:04 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default 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  
Old May 30th, 2004, 06:23 PM
Paul
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.