低版本中mysql不支持在limit语句中有子查询
Posted 汤高
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了低版本中mysql不支持在limit语句中有子查询相关的知识,希望对你有一定的参考价值。
select * from exec_activity_effect_day oe where oe.ACTIVITY_ID in (select DISTINCT(e.ACTIVITY_ID) from exec_activity_effect_day e limit 0 ,3)
[SQL] select * from exec_activity_effect_day oe where oe.ACTIVITY_ID in (select DISTINCT(e.ACTIVITY_ID) from exec_activity_effect_day e limit 0 ,3)
[Err] 1235 - This version of mysql doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
低版本中mysql不支持在limit语句中有子查询
所以只要在有limit的语句里再向外包一层
( select t.ACTIVITY_ID from (select DISTINCT(e.ACTIVITY_ID) from exec_activity_effect_day e limit 0 ,3) as t)
把上面的结果作为一个新的t表
再查t表就ok ,整个语句如下
SELECT
*
FROM
exec_activity_effect_day oe
WHERE
oe.ACTIVITY_ID IN (
SELECT
t.ACTIVITY_ID
FROM
(
SELECT DISTINCT
(e.ACTIVITY_ID)
FROM
exec_activity_effect_day e
LIMIT 0,
3
)AS t
)
以上是关于低版本中mysql不支持在limit语句中有子查询的主要内容,如果未能解决你的问题,请参考以下文章