I have a table with rows that's grouped if the date and the category 'bar' matches, now I need to INNER JOIN
these with another table and use a WHERE answer = '2'
from that table, but I don't know how to do that.
SELECT category, date, client
FROM sbs_events
WHERE category <> 'bar'
UNION ALL
SELECT category, date, MIN(client) AS client
FROM sbs_events
WHERE category = 'bar'
GROUP BY category, date
I've made a SQL Fiddle
The thing I need to add to the fiddle is
INNER JOIN sbs_userEvents
ON sbs_events.id = sbs_userEvents.event_id
WHERE answer = 2
AND user_id = 1
But since I already have a WHERE category = 'bar'
I don't know how to add this.