filter duplicates in SQL join

Posted by Will on Stack Overflow See other posts from Stack Overflow or by Will
Published on 2010-06-12T19:06:51Z Indexed on 2010/06/12 19:12 UTC
Read the original article Hit count: 232

Filed under:
|
|
|

When using a SQL join, is it possible to keep only rows that have a single row for the left table?

For example:

select * from A, B where A.id = B.a_id;

a1 b1
a2 b1
a2 b2

In this case, I want to remove all except the first row, where a single row from A matched exactly 1 row from B.

I'm using MySQL.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql