Skip to main content
Inspiring
February 20, 2007
Question

DB Field CONTAINS

  • February 20, 2007
  • 6 replies
  • 598 views
I have a field in a table that contains a description of a product. So to search on this field I try this

SELECT *
FROM products
WHERE description CONTAINS ('#searchword#')

This doesn't work. Get a syntax error. What simple little thing am I overlooking?
This topic has been closed for replies.

6 replies

Inspiring
February 20, 2007
Cool! I love learning something I didn't know before, Dinghus.

Thanks,

Mike
Inspiring
February 20, 2007
Oh. It has to be
SELECT *
FROM table
CONTAINS ('#searchword#')

Inspiring
February 20, 2007
Hmmmmm CONTAINS may be just for T-SQL or ORACLE then.
Inspiring
February 20, 2007
Sorry - I see you already had the answer.

I don't know if it's just my machine, but it keeps taking forever to submit a page in my browser.
Inspiring
February 20, 2007
Use "LIKE", i.e. -

SELECT *
FROM products
WHERE description LIKE ('%#searchword#%')

- Mike

Inspiring
February 20, 2007
SELECT *
FROM products
WHERE description CONTAINS ('#searchword#')

This doesn't work. Get a syntax error. What simple little thing am I
overlooking?

That Contains is a ColdFusion Function. The SQL equivlent is LIKE.

SELECT *
FROM products
WHERE description LIEK('%#searchword#%')

Note the '%' percent signs. These are the wild card characters in SQL.