17,382
社区成员




SQL:select * from table_a where a_row_1 in (select a_row_1 from table_b where b_id = '123456');
单独执行括号中的select a_row_1 from table_b where b_id = '123456' 则会报错说table_b表中没有a_row_1字段
但整体执行这个SQL就可以得出结果,结果集和执行语句select * from table_a一样。
通过网上寻找和测试发现,产生这个的原因是因为 第一个里面的a_row_1值会把第二个的a_row_1覆盖。
(select a_row_1 from table_b where b_id = '123456')
首先 a_row_1 是从 table_a 表中查到的值
比如 a_row_1 = 'Chinese'
那么在执行(select a_row_1 from table_b where b_id = '123456') 的时候
就变成了 (select 'Chinese' from table_b where b_id = '123456')
所以没有 起到过滤作用
希望能对你们有所帮助