question re: multiple where values

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

question re: multiple where values

Post by voltrader »

I would like to select a name field based on a PK field (ref).

I'm using this statement:

Code: Select all

$mysql="SELECT name FROM $detail WHERE ref='29, 30, 2, 4, 25'";
The intent is to get multiple names from the records with those ref numbers, but the statement seems to only pick up the name with ref=29.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Figured it out... needed an 'IN'

Code: Select all

$mysql="SELECT name FROM $detail WHERE ref IN '29, 30, 2, 4, 25'";
Post Reply