Comma separated value & wildcards in mysql

前端 未结 2 1867
没有蜡笔的小新
没有蜡笔的小新 2021-01-24 21:18

I have a value in my database with comma separated data eg.

11,223,343,123

I want to get the data, if it match a certain number (in this exampl

2条回答
  •  春和景丽
    2021-01-24 21:57

    Storing stuff in a comma separated list usually is a bad idea, but if you must, use the FIND_IN_SET(str,strlist) function.

    WHERE FIND_IN_SET('223',wp_postmeta.meta_value)
    

    If you can change your database and normalise it, you would get faster results. Create an extra table that links meta_values to your primary_id in your table.

提交回复
热议问题