日期:2014-05-18  浏览次数:20429 次

mysql不让limit 1
table
SQL code
select * from data where sku in (SELECT sku FROM `data` where sku ='40035059' and status=0 group by intPo order by id limit 1)

错语是:
#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' 
但是这样是可以的
SELECT sku FROM `data` where sku ='40035059' and status=0 group by intPo order by id limit 1

数据如下
intPo sku
123 40035059
123 40035059
124 40035059
125 40035059
256 40035088

------解决方案--------------------
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

这个提示很清楚了,当前版本不支持in+limit的形式。

就是说
SQL code

select * from data 
where sku in 
(
select sku from `data` 
where sku ='40035059' and status=0 
group by intpo order by id limit 1
) --这个limit 在in后面的括号里面就是不行的了

------解决方案--------------------
SQL code

select * from data where sku in 
(SELECT sku FROM `data` where sku ='40035059' and status=0 group by intPo order by id limit 1)