I have a table members:
member_id, points
And I have another table bets:
member_id, finished
Consider following data for table members:
1 0
2 15000
3 0
And for bets:
1 -1
1 0
2 1
3 1
3 -1
In the table bets finished = -1 marks the bet as lost, 0 as unfinished and 1 as won.
How can I select member id’s which have 0 points and all their bets are finished? With the data I have given, it should return one row with member id = 3.
You could use EXISTS clause:
You can also use a LEFT JOIN: