i want to match 2 comma separated string in 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`
i heard about LOCATE syntax but don't know to use.
SELECT * FROM jobs_posted_by_employer WHERE skills [don't know]
i have kept my table online for query execution!!!
here is my Query:http://sqlfiddle.com/#!9/b1931
Using regexp (you need reformat a little your input with PHP) : http://sqlfiddle.com/#!9/b1931/13
select
*
from
jobs_posted_by_employer
where
skills regexp '(^|,)Housekeeping|Cleaning|Other(,|$)'
or without PHP reformat : http://sqlfiddle.com/#!9/b1931/40
select
*
from
jobs_posted_by_employer
where
skills regexp concat(
'(^|,)',
replace('Housekeeping,Cleaning,Other',',','|'),
'(,|$)'
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With