As others have said, you can use 'IN'. You could also use UNION (although I
don't think I would, personally, for quite what you want!):
SELECT word FROM word_table WHERE id = 1
UNION
SELECT word FROM word_table WHERE id = 2
Etc. Assuming your version of MySQL supports the UNION operator!
Another option (although less elegant than 'IN') is to create a temporary
table with one column, 'word_id' or similar, and insert all of the IDs you
wish to search for in there. You can then INNER JOIN to that table:
SELECT word FROM word_table wt INNER JOIN id_table it ON it.word_id = wt.id
It all depends on how you're doing this, and exactly what you want. :)
Cheers,
Matt
-Original Message-
From: Matthias Eireiner [mailto:[EMAIL PROTECTED]
Sent: 26 April 2004 23:00
To: [EMAIL PROTECTED]
Subject: simplifying OR clauses
hi there,
I have a basic question:
how can I simplify multiple OR statements in a WHERE clause where I have
only one column to which I refer?
e.g.
SELECT word FROM word_table WHERE id = 1 OR id = 34 OR id = 78 OR id =
8787
OR ...
I thought I once read over something like this but I can't find it right
now. Would be great if somebody could help me out!
Thanks a lot in advance!
regards
Matthias
_
Matthias Eireiner
email: [EMAIL PROTECTED]
www.bvcapital.com
_
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]