Given a list of 6-digit strings (representing a portion of a Social Security Number), I need to pull back a dataset of users whose SSN matches one of those strings. My SQL is:
SELECT DISTINCT
u.ssn,
u.name
FROM user u
WHERE (u.ssn LIKE '%111111%' OR u.ssn LIKE '%222222%')
I'd like to use a prepared statement instead of generating inline SQL (injection attacks, etc.) Is there a way I can get my data back without creating inline SQL?
There are similar questions on this site, but the problem in my case is that using an IN clause instead of LIKE is not an option. I'm only given 6 digits and have to search for the entire 10-digit SSN.
p.s. This is a .Net application with a SQL Server back end.