Hello.

On Mon 2003-02-24 at 11:28:05 +0000, [EMAIL PROTECTED] wrote:
> Hello,
> 
> In a table like this:
> 
> ID
> Item1 char(100)
> Item2 char(100)
> .
> .
> ItemN char(100)
> 
> What's the cleanest way to do this mysql query:
> 
> SELECT * FROM MyTable WHERE AnyColumn LIKE '%mysearch%'
> 
> Only way I can think to do it is:
> 
> SELECT * FROM MyTable WHERE (Item1 LIKE '%mysearch%' OR Item2 LIKE 
> '%mysearch%' OR .... )

Yes, that's it. If you think that's unpretty, you are right. With a
normalized design, you usually shouldn't need such a query. In other
words, if you find yourself needing to do such queries regularly, you
may want to re-evaluate your database design.

Depending on the context, a look at FULLTEXT indexes may be helpful,
too.

HTH,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to