内部mysql会把in语句的执行语句转化为exists。
explain select a.* from t_app_digital_parameter a where digital_id in (select id from t_app_digital_product GROUP by product_category)
它会默认的转化为exists语句的查询。
所以对于上述的语句,可以自己写一条使用exists来执行。
explain select a.* from t_app_digital_parameter a where exists(
select b.* from (select id from t_app_digital_product b GROUP by b.product_category) b where a.id =b.id);
explain select a.* from t_app_digital_parameter a where digital_id in (select id from t_app_digital_product GROUP by product_category)
它会默认的转化为exists语句的查询。
所以对于上述的语句,可以自己写一条使用exists来执行。
explain select a.* from t_app_digital_parameter a where exists(
select b.* from (select id from t_app_digital_product b GROUP by b.product_category) b where a.id =b.id);
本文探讨了MySQL如何将IN子查询转换为EXISTS子查询以提高查询效率,并提供了具体的SQL示例来展示这一过程。
892

被折叠的 条评论
为什么被折叠?



