MySQL使用IN子查询包含LIMIT报错MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'解决

2021-11-14 155点热度 0人点赞 0条评论

问题描述

想要在查询中用in中使用limit

SELECT * from t_order where order_no in (
SELECT distinct order_no from t_order where order_no is not null and order_no <> '' limit 0, 2
)

报错:

1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery', Time: 0.010000s

问题解决

在子查询中再套一层,对in来说,就没有直接的limit了

SELECT * from t_order where order_no in (
select order_no from (SELECT distinct order_no from t_order where order_no is not null and order_no <> '' limit 0, 2) as t1
)

 

admin

这个人很懒,什么都没留下

文章评论

*

code