0

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.

2
  • How are you building that query? Commented Jan 24, 2014 at 22:45
  • Have a look at this question, which does the same thing but with space delimiting. Basically you want to match %,X, X,%, %,X,% and X, where X is the search string. You could also do a regex search, but that's not as efficient. Commented Jan 24, 2014 at 22:45

1 Answer 1

1

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;
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I tried the find_in_set before and it didn't work, I guess I didn't realize the the spaces after the commas mattered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.