You are here: Re: MySQL Beginner REGEXP question « PHP SQL « IT news, forums, messages
Re: MySQL Beginner REGEXP question

Posted by Kimmo Laine on 08/25/05 15:18

"muldoonaz" <muldoonaz@gmail.com> wrote in message
news:1124901081.084482.271100@g14g2000cwa.googlegroups.com...
> For those of you who braved looking at this thread, i commend thee.
> out of all the PHP and MySQL work I've done, REGEXP is purely chinese
> to me. Thus I seek all of you out there with knowledge about REGEXP
> that is far greater than mine.
>
> I have a database with comma separated values (ie. 2,3,4,5 [note, no
> leading or trailing commas]) that cross-reference to another table's
> ID's. I need a way to send a SQL query to the db to search within the
> comma separated values and find whichever entries match the search.
>
> Mind you, LIKE doesn't work (at least I haven't been able to get it to
> work). For instance, LIKE %4% will pull up entries with 4, but also
> with 44, 444, 4444, 14, 24, you get the idea. Thus REGEXP seems the
> way to go.


But MySQL has a native fieldtype SET that _can_ hold multiple values. Doing
queries against SET should solve the problem you described. But that sort of
datatype is bad design practise. The rule of thumb is that one field
contains one piece of information, not several. That's why you are in
trouble now, and that's why SET is not recommended by MySQL either. They've
implemented it deprecated. It's there, but you shouldn't use it.

http://dev.mysql.com/doc/mysql/en/set.html

Sorry about the nature of my answer, but I'm all thumbs with regExp, just as
you, so I decided to mock your design instead. ;)

--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
eternal piste erection miuku gmail piste com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация