I have a list of certain data (basically a number) that is separated by commas.
If I wanted to make conditions in my query to the database, what is the best way?
code:
SELECT *
FROM attributes
WHERE attribute_values = #form.searchsize#
The #form.searchsize# (if your curious to what kind of variable, it is coldfusion) is a variable passed on through a form. I basically need the field attribute_values to be searched in a each record. Each attribute_values contains several size numbers. IE - 1,2,3,4,5,.... How would I be able to question the database if #form.searchsize# is one of these numbers in the list?
SELECT attribute_values
FROM attributes
WHERE FIND_IN_SET('#form.searchsize#',attribute_values)
Something like this?
I tried this and could not get it to work.
Basically I need to know if the #form.searchsize# variable is within the data (separated by commas, therefore commas are the delimiter) in each table within the attribute_values field.
attribute_values (MS Access Field)
1,2,3,4,5
1,2,3,4,5,6,7
2,3,4,5,6,7
5,6,7,8,9
I need to check each row's attribute values and see if my #form.searchsize# variable is in it's list.
Last edited by bradleybebad; 06-12-2009 at 12:46 PM.
Sorry, I guess find_in_set is just a mysql thing. I don't know Access, but I'd assume there's some sort of string search function.
Maybe using IN would work:
Bookmarks