Difference between revisions of "Full text search"
From SQLZOO
(Created page with "Full text search with SQL? such as i want to find a specific word in any colum of the table <div class='ht'> <div> The "brute force" method is to use use the LIKE operator aga...") |
|||
| Line 1: | Line 1: | ||
Full text search with SQL? such as i want to find a specific word in any colum of the table | Full text search with SQL? such as i want to find a specific word in any colum of the table | ||
<div class='ht'> | <div class='ht'> | ||
| + | <div class=params>schema:gisq</div> | ||
<div> | <div> | ||
The "brute force" method is to use use the LIKE operator against any of the | The "brute force" method is to use use the LIKE operator against any of the | ||
| Line 13: | Line 14: | ||
</source> | </source> | ||
| − | <source lang='sql' class='def e-oracle'>SELECT name FROM | + | <source lang='sql' class='def e-oracle'>SELECT name FROM bbc |
WHERE lower(name) LIKE '%the%'</source> | WHERE lower(name) LIKE '%the%'</source> | ||
| − | <source lang='sql' class='def e-sqlserver'>SELECT name FROM | + | <source lang='sql' class='def e-sqlserver'>SELECT name FROM bbc |
WHERE name LIKE '%the%'</source> | WHERE name LIKE '%the%'</source> | ||
| − | <source lang='sql' class='def e-mysql'>SELECT name FROM | + | <source lang='sql' class='def e-mysql'>SELECT name FROM bbc |
WHERE name LIKE '%the%'</source> | WHERE name LIKE '%the%'</source> | ||
| − | <source lang='sql' class='def e-access'>SELECT name FROM | + | <source lang='sql' class='def e-access'>SELECT name FROM bbc |
WHERE name LIKE '%the%' | WHERE name LIKE '%the%' | ||
</source> | </source> | ||
| − | <source lang='sql' class='def'>SELECT name FROM | + | <source lang='sql' class='def'>SELECT name FROM bbc |
WHERE name LIKE '%the%' | WHERE name LIKE '%the%' | ||
</source> | </source> | ||
Revision as of 13:14, 12 July 2012
Full text search with SQL? such as i want to find a specific word in any colum of the table
schema:gisq
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 bbc WHERE LOWER(name) LIKE '%the%'
SELECT name FROM bbc WHERE name LIKE '%the%'
SELECT name FROM bbc WHERE name LIKE '%the%'
SELECT name FROM bbc WHERE name LIKE '%the%'
SELECT name FROM bbc WHERE name LIKE '%the%'