At 13:53 24/02/03 +0100, you wrote:
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.

Can I not do:


WHERE CONCAT(Item1,Item2....,ItemN) LIKE '%mysearch%'

?

Jeff


--------------------------------------------------------------------- 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