Skip to main content
Inspiring
April 30, 2007
Question

Searching on a field

  • April 30, 2007
  • 2 replies
  • 286 views
This one is baffling me to no end. I have a store with a db of products and descriptions. So of course I want the visitor to be able to search the db for what they want.

When I test the query in the query builder in access it works fine. Does what it is supposed to do. Then I move it to ColdFusion and it only returns values where the search word is the first word in the description field.

SELECT productid, productname
FROM products
WHERE productdescription LIKE '%#searchword#%'
GROUP BY productid, productname
ORDER BY productname

Why doesn't this work right in CFQUERY but works fine in Access query builder?
This topic has been closed for replies.

2 replies

Inspiring
May 1, 2007
try removing the GROUP BY clause from your query and see if that works.
i remember having similar sort of trouble and i think that was what
solved it...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
Inspiring
April 30, 2007
Its hard to say without more specific information.

1. Try trimming the #searchword# to see if its a problem with trailing spaces
2. Turn on debugging. Then copy the exact sql query from the output and paste it into Access and check the results.

Debugging:
SQL Queries
GetProducts (Datasource=TestDSN, Time=0ms, Records=3) in C:\CFusionMX7\wwwroot\Test.cfm

SELECT *
FROM Products
WHERE productdescription LIKE '%oranges%'
Inspiring
May 1, 2007
Well, that would work IF the host allowed debugging. Appears not to.