As Dan alluded to, you need to fix your data model. However,
you say you can't do this, but you ask: "how do I write the WHERE
clause in SQL?"
SQL isn't designed to help you continue to use a faulty data
model. Thus, there isn't a nice way to write what you want, and
it's going to be dog-slow.
For each item in the list you're searching for (4,90 in your
example), you need to check 4 options:
Is this element at the beginning of my list? WHERE row LIKE
'#element#,%'
Is this element at the end of my list? WHERE row LIKE
'%,#element#'
Is this element in the middle of my list? WHERE row LIKE
'%,#element#,%'
Is this the only element in the list? WHERE row = '#element#'
You can see how this gets crazy.
<cfset listToSearchFor = "4,90">
<cfquery ...>
SELECT * FROM tablename WHERE
<cfloop list="#listToSearchFor#" index="idx">
row LIKE '#idx#,%' OR
row LIKE '%,#idx#' OR
row LIKE '%,#idx#,%' OR
row = '#idx#' OR
</cfloop>
1 = 2
</cfquery>
All of these OR LIKE checks are gonna make the query slower
and slower.
In the future, never EVER store a comma-delimited list in a
database field. You want to break it out into another table. How do
you do that? I'm glad you asked... In your example, where Row 1 =
"45,67,2,90,67", assume the primary key for that row is "12"...
Main_Table
---------------
id
Whatever_Table (You'd name this table based on what these ids
stand for in the row list)
--------------------
main_id foreign key references main_table(id)
whatever_id
So your Main_Table would have an entry with an ID of 12 and
Whatever_Table would contain:
main_id whatever_id
12 45
12 67
12 2
12 90
12 67
Now you can get all the whatever_id values for a given
main_id by:
select whatever_id from whatever_table where main_id = 12;
And to answer your original question, you can do:
SELECT Main_Table.* FROM Main_Table JOIN Whatever_Table ON
(Main.id = Whatever_Table.main_id)
WHERE whatever_id IN (4,90)
Lots easier, huh?