Friday, July 5, 2024

SQL command to search for a list of data

Have a list of data that you want to look up in a single SQL command?   Here's a syntax you can try.

We'll be using the "IN" command

Data needs to be comma delimited and encapsulated in parentheses 

Select * from TABLE_NAME

where COLUMN_NAME in ('DATA1', 'DATA2', 'DATA3', 'DATA4') 


example

Select * from CustomerData

where UserName in ('JBsmith', 'RDAndrews', 'BIJones', 'KARing')