Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
クエリを書く必要があります
select count(*) cnt from tabel1,table2 where table1.a=table2.b
カウントを 0 1 2 として表示します
上記のクエリをサブクエリとして使用することにより、テーブル 1 から ID をフェッチする必要があります。カウントは 1 と 2 のみである必要があります。
提案してください
これを試して
select a.a , count(b.b) from table1 a join table2 b on a.a = b.b group by a.a having count(b.b) > 0
してみてください:
select a.id , count(*) from table1 a join table2 b on a.id = b.id group by a.id having count(*) IN (1, 2)