Full text search

From SQLZOO
Revision as of 11:34, 11 July 2012 by Marek (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Full text search with SQL? such as i want to find a specific word in any colum of the table

The "brute force" method is to use use the LIKE operator against any of the fields to be searched. This will be relatively expensive - but probably good enough in many cases. The term to search for should be quoted and placed within two wild cards.

You should construct the string literal in some scripting language - don't forget to quote it.

 
SELECT name FROM scott.cia
WHERE LOWER(name) LIKE '%the%'
SELECT name FROM gisq.cia
WHERE name LIKE '%the%'
SELECT name FROM gisq.cia
WHERE name LIKE '%the%'
SELECT name FROM cia
WHERE name LIKE '%the%'
SELECT name FROM gisq.cia
WHERE name LIKE '%the%'
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense