Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass a list to where clause in Select

Status
Not open for further replies.

Vinni

Programmer
Aug 14, 2002
11
US
Hi there,

I am making a list of group_id to be searched in a table. Can I pass this list as is to the 'where' clause rather having to iterate the list.

The list of group_id is {23 45 56}

My original SQL looks like:

SELECT t.rootid, t.msgtranslation, t.msgimagepath
from msgcat_root r, msgcat_translation t
where r.group_id = $groupId
and r.rootid = t.rootid
and t.clid = $localeId

can I use it like : where r.group_id = {23 45 56}

thanks
 
use IN and parentheses, and make sure the commas are retained

Code:
where r.group_id IN (23, 45, 56)

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top