My tables are:
frequents(bar,drinker);
likes(beer,drinker);
serves(bar,beer)
I want to "select pairs of drinkers who frequents exactly the same bars".I think I can write that query using only the frequents table (as it has both bar and drinker column) using self joints I tried to do but couldn't get it.I don't mind using other tables too to get the exact query.The query must select drinkers who goes to the same bars only.In other words they should have all the the bars in common.The query must be in generalized form it should not depend on data that's why I didn't put any data.
DRINKER | BAR
____________________
John | Hyatt
Smith | Blue
William | Hilton
John | Geoffreys
Smith | Hyatt
Joe | Blue
Mike | Hilton
William | Dublin
Jeff | Hilton
Jake | Hilton
This is my frequents table I need to select only Joe and Smith and also Jake and Jeff because they visit exactly the same bars.
select drinker from frequents where bar = "bar1"and repeat that 4 more times