You can use join
and group by
. Assuming you have no duplicates in userrecords
(as in your sample data):
select ur.userid
from userrecords ur join
lookup lu
on ur.record = lu.id
group by ur.userid
having count(*) = (select count(*) from lookup);
If you do have duplicates in userrecords
, then use count(distinct record)
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…