我希望在match
中以string
2个逗号分隔mysql
,
test string
=> Housekeeping,Cleaning,Other
。
| skills |
+-------------------------------------+
| Housekeeping,Cleaning,Sweeping |
+-------------------------------------+
| Housewives,Beautician,Cleaning | AGAINST `Housekeeping,Cleaning,Other`
+-------------------------------------+
| PHP,Laravel,Other |
+-------------------------------------+
| Housekeeping,housekeeping,other |
+-------------------------------------+
MUST MATCH => All the `rows`
我听说过LOCATE
语法,但不知道如何使用。
SELECT * FROM jobs_posted_by_employer WHERE skills [don't know]
我保留了table
在线以查询execution
!!!
答案 0 :(得分:2)
使用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',',','|'),
'(,|$)'
)