我需要设置一个SELECT查询,该查询将根据具有逗号分隔列表的列中的匹配字符串返回行。
以下是数据示例:
path title desc type feed_type markets tags
IMG_5639.jpg Malta Title description photo sheetfed tobacco,education gatefolds,accordian
IMG_5672.jpg Malta Title description conceptual inline magazine gatefolds,oversized
IMG_5689.jpg Malta Title description conceptual digital non-profit oversized
IMG_5691.jpg Malta Title description photo sheetfed automotive oversized,obtuse
IMG_5694.jpg Malta Title description photo inline tobacco postcard,oblong
IMG_5699.jpg Malta Title description conceptual digital education oversized,obtuse
IMG_5701.jpg Malta Title description conceptual sheetfed service postcard,oblong
01.jpg Barcelona Title barcelona conceptual sheetfed service diecut
02.jpg Barcelona Title barcelona photo inline education postcard,oblong
03.jpg Barcelona Title barcelona photo digital associations gatefolds,accordian
答案 0 :(得分:2)
I think, you should normalized your data properly? A single column should never contain a comma seperated string of names.
otherwise in most cases you would not get proper output.
答案 1 :(得分:0)
尝试使用Google搜索LIKE子句。
除非用户在其搜索查询中添加逗号,否则以逗号分隔的位无关紧要。
在这种情况下,如果您可以更改数据库架构,我会将CSV数据的每一列放入其自己的数据库列中。这将允许您单独查询每列。