MySQL Forums
Forum List  »  Newbie

Re: search comma separated db column
Posted by: Rick James
Date: March 31, 2009 11:36PM

Can I play, too? Call me something other than "troll", that name is taken.

REGEXP, with the word boundary markers:

mysql> select * from commas where a REGEXP '[[:<:]]32[[:>:]]';
+---------+
| a |
+---------+
| 7,32,87 |
+---------+

mysql> select * from commas where a REGEXP '[[:<:]]3[[:>:]]';
+-------------+
| a |
+-------------+
| 1,2,3,23,77 |
+-------------+

mysql> select * from commas where a REGEXP '[[:<:]]7[[:>:]]';
+---------+
| a |
+---------+
| 7,32,87 |
+---------+

http://dev.mysql.com/doc/refman/5.0/en/regexp.html

Options: ReplyQuote


Subject
Written By
Posted
Re: search comma separated db column
March 31, 2009 11:36PM


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.