I have the following SQL query:
SELECT * FROM UserTags INNER JOIN Events ON UserTags.E_ID=Events.E_ID WHERE ID = 2 AND Tag='coffee' OR Tag='breakfast_brunch' OR Tag='scandinavian'
This is returning the incorrect result, as it is returning columns where `ID!=2'. I believe this its trying to match the first two, followed by the others? I would like the query to only match when ID=2 in any situation.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
SELECT * FROM UserTags INNER JOIN Events ON UserTags.E_ID = Events.E_ID WHERE ID = 2 AND Tag = 'coffee' OR Tag = 'breakfast_brunch' OR Tag = 'scandinavian'