今天要实现一个功能,于是构造如下SQL语句:
select * from tx_dailylabel where dl_type='3' and d_id in (select train_id from tx_training where train_isdelete=0 and train_isdraft=0 and train_ischeck=0 limit 0,10) ;
执行该语句,MySQL提示错误:
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
无奈Google之,发现解决办法就是再子查询中再嵌套一层查询:
select * from tx_dailylabel where dl_type='3' and d_id in (select train_id from (select train_id from tx_training where train_isdelete=0 and train_isdraft=0 and train_ischeck=0 limit 0,10) as table1)
一测试居然可以,不由得感叹,人民群众真是智慧的群体啊,于是记录于此。
本文介绍了一种在MySQL中解决LIMIT与IN/ALL/ANY/SOME子查询不兼容问题的方法。通过在子查询中增加额外一层查询来绕过限制,确保了查询能够正确执行。
5198

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



