"David Beech" <[EMAIL PROTECTED]> wrote:
> On 12 Apr 2001, at 13:54, Jim Zarvis wrote:
>
> > What is good clean sql syntax to accomplish the following with MySQL:
> > SELECT * FROM tablename WHERE value is in array of values
> >
> > i.e. (psudocode)
> >
> > Assume I have a field called ID in my table, and that I have 20 Rows
(with
> > ID's 1-20)
> >
> > myarray = (1,3,4)
> >
> > I want to return all the fields where ID = 1 and 3 and 4
> >
> Perhaps:
>
> SELECT * FROM tablename WHERE value >= LOWEND and value <=
> HIGHEND

Jim didn't want to return records with sequential IDs so that will not work.
A few of us suggested using the IN operator, which is the optimal solution.

SELECT * FROM table_name WHERE field_name IN (1,3,4);

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to