I have found regexp select statements useful for databases which have fields of comma-separated numbers. If I need to select all rows with a given number in such a comma-separated list, a regular expression using word boundries would work:
[[:<:]] |
left word boundary |
[[:>:]] |
right word boundary |
The below will locate all rows with number "23" in their comma-seperated list:
mysql> select id,photos from categories where photos regexp "[[:<:]]23[[:>:]]";
Source: http://www.phototour.minneapolis.mn.us/linux/regexp
1 Comment
me salvaste