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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List comparison in Where statement?

Status
Not open for further replies.

SBrisson

Programmer
Jan 7, 2007
1
US
I have a database field that contains a list of values, and I want to be able to compare that against another list of values and return all rows that have any values matching.

i.e. database field A values:
Row 1 field A = (1,2,3)
Row 2 field A = (1,5)
Row 3 field A = (6,9)

User values = (2,3,6)

Select * From table Where field A list IN? user values list

Result would return rows 1 and 3

I know I can compare a single value in a database field against a list using the IN operator (ie. where 1 IN (1,2,3)). Does anyone know how to check list to list in SQL, or if it is even possible?

Thank you.
 
Generally storing lists in columns is not a very good solution... Maybe you should consider re-designing your tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top