Reputation: 115
Given
create table account (
id int not null,
name varchar(100),
country varchar(100),
primary key (id)
);
create table score (
id int not null,
game_name varchar(100),
score int
);
How do I find accounts who played only one game please? account.id should match score.id. Thanks.
Upvotes: 0
Views: 483
Reputation: 72175
If I understood your requirement correctly, then you look for something like this:
SELECT *
FROM account
WHERE id IN (SELECT id
FROM score
GROUP BY id
HAVING COUNT(*) = 1)
Upvotes: 2