MySQL Forums
Forum List  »  PHP

Re: Trying to retrieve data where a variable is in an array
Posted by: Rick James
Date: February 21, 2010 10:37AM

LIKE '%3%' will incorrectly catch 13.
LIKE '%,3,%' will fail on '3,4,5,6,7'
etc.

This is a common discussion:
http://forums.mysql.com/read.php?10,274102 (Setting up some new tables)
http://forums.mysql.com/read.php?10,259969 (parse by delimiter and search a data field?)
http://forums.mysql.com/read.php?10,258430 (Iterating through SQL table)
http://forums.mysql.com/read.php?20,244989 (Split Values by comma and Check in another Table?)
http://forums.mysql.com/read.php?10,249227 (Column for mutiple and not-predefined values)
http://forums.mysql.com/read.php?10,277624 (MYSQL LIKE and REGEXP style query help needed)
http://forums.mysql.com/read.php?10,271995 (help in select ... where ...like...)
http://forums.mysql.com/read.php?10,206857,255573 (search comma separated db column)

In those you will find 3 things:
* "Don't design your table that way!"
* FIND_IN_SET() (slow)
* a REGEXP (RLIKE) that does work (slow)

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.