List:General Discussion« Previous MessageNext Message »
From:Johan Gant Date:July 24 2008 1:43pm
Subject:Re: WHERE .... IN
View as plain text  
Hi

If you're searching for, effectively, %123% you probably can't use IN(). You
could get away with wildcard patterns - if it's a heavily used field
consider an index to increase performance. Hard to tell if this may be a FK
of sorts, but if so you should use it as one which may involve normalising
your tables. Also, if this is a field of type int you may need to cast your
data as varchar to perform wildcard searches.

Regards

Johan Gant

2008/7/23 Ali Deniz EREN <ali.deniz.eren@stripped>:

> Hi all,
>
> I have a problem as below:
>
> A text field -Lets call it 'field1'- contains datas seperated by
> commas(,) like this (123,5764,8795,9364,11,232,..... and go on) And so
> my lines like these:
>
> id      title      filed1
> -------------------------------------------------------------
> 1      title1      123,576412
> 2      title2      123
> 3      title3      576412,8795,123
> 4      title4      123
> 5      title5      576412,1164,12,232
> ..      ...          ...
> ..      ...          ...
>
> I am looking for lines which includes the matched value within the
> field1 seperated case. For example:
>
> "SELECT id, title, field1 FROM mesaj WHERE 123  IN (field1)"
>
> result is.
> 1      title1      123,576412
> 2      title2      123
> 4      title4      123
>
> But I want it to match with third one.
> 3      title3      576412,8795,123
>
> Because it have a 123 at the end. But It does not! :(
>
> Is there another way to do this. LIKE doesn't work because
>
> "SELECT id, title, field1 FROM mesaj WHERE field1 LIKE 12" returns
> many result which is not my intention.
>
> Thank you.
>
>
> --
> Ali Deniz EREN
> ali.deniz.eren@stripped
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>

Thread
WHERE .... INAli Deniz EREN23 Jul
  • Re: WHERE .... INPeter Brawley23 Jul
  • Re: WHERE .... INMr. Shawn H. Corey23 Jul
    • Re: WHERE .... INSivasakthi24 Jul
      • Re: WHERE .... INMr. Shawn H. Corey24 Jul
  • Re: WHERE .... INJohan Gant24 Jul