首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

关于mysql关联子查询与非关联子查询的有关问题

2012-06-16 
关于mysql关联子查询与非关联子查询的问题select * from t1 where x in (select x from t2)为什么表t4的查

关于mysql关联子查询与非关联子查询的问题
select * from t1 where x in (select x from t2)


为什么表t4的查询计划结果是DEPENDENT SUBQUERY 依赖外部查询的子查询


用extended+show warnings得到重建后的查询
select `test`.`t3`.`x` AS `x`,`test`.`t3`.`y` AS `y` from `test`.`t3` where <in_optimizer>(`test`.`t3`.`x`,<exists>(select 1 from `test`.`t4` where (<cache>(`test`.`t3`.`x`) = `test`.`t4`.`x`)))

请问为什么这样优化呢, 效率很高吗??????????????????????????

[解决办法]
select * from t1,t2 where t1.x=t2.x
[解决办法]
select * from t1,t2
where t1.x=t2.x;

热点排行