MySQL query finding values in a comma separated string

后端 未结 11 1582
孤独总比滥情好
孤独总比滥情好 2020-11-21 23:40

I have a field COLORS (varchar(50)) in a my table SHIRTS that contains a comma delimited string such as 1,2,5,12,15,. Each number repr

11条回答
  •  半阙折子戏
    2020-11-22 00:03

    If you're using MySQL, there is a method REGEXP that you can use...

    http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp

    So then you would use:

    SELECT * FROM `shirts` WHERE `colors` REGEXP '\b1\b'
    

提交回复
热议问题