先創建兩個表,隨便添加一些數據
create table tableA(
id int,
name varchar(20)
)
create table tableB(
age int,
gender int
)
insert into tableA values (1,'a'),(2,'b'),(3,'c')
insert into tableB values (20,0),(30,1),(40,0)
然後執行一條錯誤語句
select * from tableA where id in (select id from tableB)
很明顯,tableB中沒有id字段,where語句應該報錯,但實際沒有,他會正常執行,並且執行結果相當於
select * from tableA where id = id
應該是sqlserver解析T-SQL的一個邏輯bug,