The answer is not in your SQL or your CFML, it is in your database schema.
If you can have multiple values for a column that column needs to be a
separate table, that's what joins are for, and that will make your SQL a
whole lot simpler.

--- Ben


-----Original Message-----
From: Les Mizzell [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 11, 2005 2:18 PM
To: CF-Talk
Subject: "like" match from a list

Yet another "driving me crazy" query problem.

I'm showing a grid of color blocks. When the user clicks on one of them, it
set a variable to look for in the database:

<cfset colorLIST = "'Teal', 'Turquoise', 'Mediterranean',  'Blue-Green',
'blue-green'">


So, here's the query

<cfquery name="srch" datasource="phoenixart">
  SELECT * FROM products
  WHERE COLOR IN (#PreserveSingleQuotes(colorLIST)#)
</cfquery>

But, here's the problem.
Database "Color" Field values for product 1:  blue-green, purple, gold
Database "Color" Field values for product 2:  blue-green


Only product 2 comes up, because the search wants to have an exact match 
to the entire field, right? So, how do I get "like" match from the list?




-- 
-----------
Les Mizzell



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:202225
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to