A. Pagaltzis wrote:
* onemind <[EMAIL PROTECTED]> [2006-06-25 16:05]:

If i had a table wit a word column that had a huge list of
words and i wanted to select every word that contained all
these letters "qdsa".


    SELECT *
    FROM words
    WHERE
        word LIKE '%q%'
        AND word LIKE '%d%'
        AND word LIKE '%s%'
        AND word LIKE '%a%'

And that’s going to be slow like molasses. It’s not something SQL
is well suited to.

If you need to do this a lot, I suggest precomputing the kinds of
facts about each word that you’ll want to query and storing them
in a column or dependent table so you can create indices and
query them quickly.

Of course if the performance of the simpleminded approach is
sufficient for you, then all the better.

Regards,
Writing a function which does the string match would be a more efficient approach.

Reply via email to