SQL语句中带IN,查询效率很慢,怎样提高查询效率?

select * from yll_shop_order where is_delete ='0' and order_no in (select order_no from yll_shop_parentorder where parentorder_no =?1)

第1个回答  2015-12-31
where parentorder_no =?1 这里加个? 是几个意思?追答

in的效率应该不会太低的。如果子查询得出的结果集记录较少,主查询中的表较大且又有索引时应该用in, 反之如果外层的主查询记录较少,子查询中的表大,又有索引时使用exists

相似回答