MySQL WHERE在PHP中匹配带有字符串的连接字符串
问题描述:
Here is my query:
SELECT * FROM events WHERE (audience like '%Internal%20Medicine%') and ('$date' < end_date) order by end_date
In the database the audience column looks like this "Internal Medicine, Neurology, Radiology".
I need the query to match the exact string in between the commas.
答
Here is a way to do this:
SELECT *
FROM events
WHERE find_in_set('Internal Medicine', replace(audience, ', ', ',')) > 0 and ('$date' < end_date)
order by end_dat;