求数据库高手写个sql语句

2025-03-25 11:33:24
推荐回答(3个)
回答1:

SELECT
DISTINCT
t1.key
FROM
t1
WHERE
t1.value in
(
SELECT
t2.value
FROM
t2
)

回答2:

select distinct key from t1 where key not in (select key from t1 a
where not exists(select 1 from t2 where value=a.value)
)

回答3:

select distinct key from t1 a
where not exists(select 1 from t2 where value<>a.value)