I am trying to solve this problem for quite some time and the output is wrong. Can anyone help me with this? I am using mysql, so full join doesnt work. Thank yyou
3 tables:
Frequents (attributes: drinker, bar, times_a_week),
Likes (attributes: drinker, beer),
Serves (attributes: bar, beer, price),
The question ask for all the drinkers who frequent "every" bar which serve some beers they like
My answer looks like this:
SELECT drinker
FROM frequents
WHERE drinker NOT IN (SELECT f.drinker FROM frequents f
JOIN likes l ON f.drinker=l.drinker
LEFT JOIN serves s ON l.beer=s.beer
AND s.bar=f.bar
WHERE s.bar IS NULL)
how about this:
if it doesn't work, can you post some example of your data?