In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Niklas lampén) wrote:

> Can it cause any problems if mySQL query is very long? I have to compare
> many words to many fields in my DB and I've done it like
> "....Field LIKE '%searchword%' || Field LIKE '%searchword%' || Field LIKE
> '%searchword%'.....". Query is build by a function, so I don't know the
> exact length but it is VERY long. I also have to compare several words to
> one field so I've done many of those "Field LIKE '%blah%'" for those too.
> Is there any smarter way to do this?

Depending on what you need the comparison to do and how bit the range of 
possible searchwords is, querying against either a "fulltext" index, an 
"enum" field, or a "set" field might work out better for you. (See the 
*MySQL* manual for more info.)

As for the where clause, AFAIK[*] the length of the query should be less of 
a concern than the fact that MySQL is not being allowed to use an index 
(because of the leading "%").  It has to do row-by-row comparisons, slowing 
down execution.

[*] Double-check that with the folks on the MySQL.com support list, though.  
It's a question better asked of them anyway...

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to