我想在match
中用逗号分隔string
,
测试。
| skills |
+-------------------------------------+
| Housekeeping,Cleaning,Sweeping |
+-------------------------------------+
| Housewives,Beautician,Cleaning | AGAINST `Housekeeping,Cleaning,Other`
+-------------------------------------+
| PHP,Laravel,Other |
+-------------------------------------+
| Housekeeping,housekeeping,other |
+-------------------------------------+
MUST MATCH => All the `rows`
我听说过
mysql
语法,但不知道怎么用。SELECT * FROM jobs_posted_by_employer WHERE skills [don't know]
我已将我的
string
保持在线,以便查询Housekeeping,Cleaning,Other
!!!我的问题是:http://sqlfiddle.com/#!9/b1931
最佳答案
使用regexp(需要用php重新格式化输入):http://sqlfiddle.com/#!9/b1931/13
select
*
from
jobs_posted_by_employer
where
skills regexp '(^|,)Housekeeping|Cleaning|Other(,|$)'
或者不使用php重新格式化:http://sqlfiddle.com/#!9/b1931/40
select
*
from
jobs_posted_by_employer
where
skills regexp concat(
'(^|,)',
replace('Housekeeping,Cleaning,Other',',','|'),
'(,|$)'
)