Page 1 of 1

Retreive more than one id

Posted: Fri Aug 20, 2004 11:13 am
by bdeonline
I need a query that can retreieve more than one id.

Code: Select all

SELECT color FROM color WHERE id='2, 4, 1'

Posted: Fri Aug 20, 2004 11:13 am
by hawleyjr

Code: Select all

SELECT color FROM color WHERE id=2 or id=4 or id = 1

Posted: Fri Aug 20, 2004 11:15 am
by bdeonline
Thanks I knew it was something super simple but the simple answers are the hardest ones to find on google.

Posted: Fri Aug 20, 2004 11:20 am
by markl999
Or:
SELECT color FROM color WHERE FIND_IN_SET(id, '1,2,4');

Posted: Fri Aug 20, 2004 9:37 pm
by fractalvibes
Or
select color from color where id in ('1','2','3')
(standard sql)

Depending on DBMS, you could also have the where clause reference the return value of a subselect if you need to qualify that group of ids rather than hard-coding them...

fv