select query with multiple parameters

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
taldos
Forum Commoner
Posts: 39
Joined: Mon Aug 23, 2004 8:47 am
Location: Philadelphia

select query with multiple parameters

Post by taldos »

what I want to accomplish:

Rather then running a query that resembles this:

Code: Select all

SELECT * FROM table1 WHERE (id LIKE 1 || id LIKE 2 || id LIKE 3 || id LIKE 4 || id LIKE 5) || (name LIKE a || name LIKE b || name LIKE c || name LIKE d)
Rather then running such a cumbersome query, is it possible to pass a comma delimited string as follow.

Code: Select all

SELECT * FROM table1 WHERE id LIKE (1,2,3,4,5) || name LIKE (a,b,c,d)
The syntax is giving me some trouble. Any hints help would be appreciated.

Thx.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

SELECT * FROM `table1` WHERE `id` IN (1,2,3,4,5) OR `name` IN (a,b,c,d)
maybe something like that?
Last edited by JayBird on Thu Aug 17, 2006 8:36 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't remember pipes being supported, should probably switch those to "OR"
taldos
Forum Commoner
Posts: 39
Joined: Mon Aug 23, 2004 8:47 am
Location: Philadelphia

Post by taldos »

that should do it. thx. :)
Post Reply