View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 09:28 AM
techcalgary@hotmail.com
 
Posts: n/a
Default select multiple values for column in one query

I have a table with a column that contains a comma seperated list of
ids as TEXT that are used to reference multiple rows in another table.
so "2,4" would reference id 2 and 4 in table2.

select * from table2 where id = 3 or id = 4;

Is there a way to do that without going through the list and
delimiting with " or id = "? Something like

select * from table2 where id in values(3,4);

I thought I'd seen something like that before but I can't find it in
the mysql manual.

Is using a TEXT for an id list bad structure? Is there a better way to
store an array of ids in a column in mysql?

Reply With Quote