Or you could just reverse the arguments to LIKE, so your field is on
the right and your string is on the left.  You may have to surround
your field with concat('%', field_name, '%') (or just use regexp), but
LIKE is a binary string comparison operator and doesn't care which, if
either, arguments are fields or constants.

(It might not use your indexes there, or be the best way to do it...
The below looks better to me, or use a join table to do it really
properly.  But in answer to your question, the 'reverse' of LIKE is
LIKE with its arguments reversed.)

--Pete


On Mon, Oct 14, 2002 at 05:26:13PM -0400, Keith C. Ivey wrote:
> On 14 Oct 2002, at 20:29, Tim Kerch wrote:
> 
> > For example, I have a string
> > "Administration,Advertising,Direction,Media,Research" and I want to see
> > whether a SECTOR field in a row is contained in the above string.
> 
> You could construct a query something like this:
> 
>     SELECT * FROM table_name WHERE sector IN ('Administration',
>         'Advertising', 'Direction', 'Media', 'Research');

sql

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