引用内容 引用内容
1. 匹配型子查询的改写
select * from table1 where column1 in (select column2a from table2 where column2b = value);
改写为:
select table1.* from table1, table2 where table1.column1 = table2.column2a and table2.column2b = value;

2. 非匹配(即缺失)型子查询的改写
select * from table1 where column1 not in (select column2 from table2);
改写为:
select table1.* from table1 left join table2 on table1.column1 = table2.column2 where table2.column2 is null;
注意:这种改写要求数据列table2.column2声明为not null