如何编写这样的请求。我在数据库中有一个日期(tableName=DateTime),id(tableName=Name)和3个表中为id定位的日期。

我需要选择id,它的日期不是在其他日期输入的。那些。如果行№3的日期不在表中,那么我将得到id=3,我这样写,但它不正确(
"select id from Name
where (select id from Name where id=3
and (date.DateTime not in (select date from DateTime)))" 发布于 2019-03-01 20:08:08
这是你想要的吗?
select n.id
from name n
where not exists (select 1
from name n2
where n2.date = n.date and n2.id <> n.id
);等效的方法是:
select max(n.id)
from name n
group by n.date
having count(*) = 1;https://stackoverflow.com/questions/54944298
复制相似问题