Art*_*tem 6 mysql sql database
我正在尝试执行 mysql 查询来查找表中不存在的 id,但出现错误。我究竟做错了什么?这是我的查询
create table scientist (id integer , firstname varchar(100), lastname varchar(100));
insert into scientist (id, firstname, lastname) values (1, 'albert', 'einstein');
insert into scientist (id, firstname, lastname) values (2, 'isaac', 'newton');
insert into scientist (id, firstname, lastname) values (3, 'marie', 'curie');
select * from (
VALUES ROW (1 , 2 , 3, 4, 5)
) as V
WHERE id not EXIST (select id from scientist);
Run Code Online (Sandbox Code Playgroud)
我期望在输出中看到 4 和 5
你会not exists这样使用:
select *
from (VALUES ROW (1) , ROW (2) , ROW (3), ROW (4), ROW (5)
) v(id)
where not exists (select 1 from scientist s where s.id = v.id);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3697 次 |
| 最近记录: |