我有以下查询,当我在子查询中使用不存在的列引用时没有错误。我在子查询中引用的列实际上是正在更新的表中的列。
create table tbl1 (f1 bigint, f2 char(10), f3 integer);
insert into tbl1 values (1, 'aa', 0);
insert into tbl1 values (2, 'bb', 0);
insert into tbl1 values (3, 'cc', 0);
insert into tbl1 values (4, 'dd', 0);
create table temp_tbl (ref_num bigint);
insert into temp_tbl values (1);
insert into temp_tbl values (3);
update tbl1 set f2='ok' where f1 in (select f1 from temp_tbl);
-- 4 records updated
谁能告诉我为什么它没有给出任何错误?无论条件如何,记录都会更新。
我在 Oracle 和 SQLserver 中都试过这个。结果是一样的