I am performing a query based on keywords provided by the user. My table simply has named entries with a "tags" column. I want to return rows whose tags match certain keywords which the user requested. So for example a typical row could look like this:
If the user requested the keywords 'water' and 'salt' then as it stands the sql looks like:
SELECT entry FROM mytable
WHERE tags LIKE '%water%' OR tags LIKE '%salt%'
.. and so on if we had more keywords to match. Is it possible to compact them into a single LIKE operation?? I'm guessing that the above would check for the 'water' match in tags, then start from scratch and check for a 'salt' match, if i have alot of rows then this may effect peformance? Ideally i'd like some sort of regular expression. I'd imagine it might look like: LIKE '(%water%|%salt%)' ??
Is it possible to do something like the above? If my current way of doing it using multiple LIKEs is the way then please let me know also.