我做错了什么?
它返回以下错误:
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
当我单独运行子查询时,子查询工作正常:
select * from emprego
where base in
(
SELECT base FROM emprego me
group by base
order by sum(TIMEDIFF(me.data_demissao,me.data_admissao)) desc
limit 1
)
答案 0 :(得分:0)
使用自联接重写您的查询
select e.*
from emprego e
join
(
SELECT base FROM emprego me
group by base
order by sum(TIMEDIFF(me.data_demissao,me.data_admissao)) desc
limit 1
) e1
on(e.base = e1.base)
答案 1 :(得分:0)
试试这个
select * from emprego
where base in
(
select * from
(
select base from emprego me
group by base
order by sum(TIMEDIFF(me.data_demissao, me.data_admissao)) desc
limit 1
) as t
)
我希望这会有所帮助。
答案 2 :(得分:0)
这是一个查询命题:
SELECT *
FROM emprego E
INNER JOIN (SELECT E2.base
,SUM(TIMEDIFF(E2.data_demissao, E2.data_admissao)) AS [duree]
FROM emprego E2
GROUP BY E2.base) D ON D.base = E.base
ORDER BY D.duree DESC
LIMIT 1
希望这可以帮助您避免在执行查询时出错。