SQL search
I have some web pages that enable users to search a database.
They can type in a keyword or phrase in a text area, and select one or more checkboxes to narrow the search.
This works well, except I would like the keyword search to be a bit more flexible.
At the moment, my SQL is effectively like this:
SELECT *
FROM myTable
WHERE myFieldNames
LIKE '%texfieldVariable%'
So I'm using LIKE and the wildcard operator at the start and end of the keyword.
This is the problem:
Say I have the following text in a field:
"we are the knights who say ni!"
If the user enters "the knights", they will retrieve the record, however, if they enter "the knight who say ni", they do not get the record.
Is there any way of making this type of keyword more flexible in SQL?
Thanks
SoC
|