データベース検索の場合、例の代わりに、inはexistsを使用します。


今はunit表があります。information表があります。unit表にnameフィールドがあります。information表にunit_があります。nameフィールドは、unitテーブルのnameフィールドから来ます。このうちinformation表には、同じunit_が複数存在する可能性があります。nameのデータ
今はunit表を調べたいですが、information表にあるunit_nameは、重複したデータがあるかどうか。
select name,count(*) from unit u where u.name in 
	(select unit_name from information i where i.unit_name = u.name)
group by u.name having count(*) > 1
修正後
select name,count(*) from unit u where exists
	(select 1 from information i where i.unit_name = u.name)
group by name having count(*) > 1
このように検索すると効率がいいです。