此版本的MySQL尚不支持'LIMIT&IN / ALL / ANY / SOME子查询

时间:2018-08-20 21:51:08

标签: php mysql

我必须从有限的2个表中获取数据,我正在使用此查询并遇到错误SELECT PlanId, StairCount, MinCount, MaxCount, CurrencyId, STUFF(( SELECT CONCAT(',', t1.AccountId) FROM YourTable t1 WHERE t1.PlanId = t.PlanId AND t1.StairCount = t.StairCount AND t1.MinCount = t.MinCount AND t1.MaxCount = t.MaxCount AND t1.CurrencyId = t.CurrencyId ORDER BY t1.AccountId FOR XML PATH('')), 1, 1, '') AS AccountIdList FROM YourTable t GROUP BY PlanId, StairCount, MinCount, MaxCount, CurrencyId

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery

我必须从“版本和软件”中选择“ Softwars.SoftId = Versions.SoftId”的“所有”列,然后从“表版本”中选择“最新版本”。 谢谢

1 个答案:

答案 0 :(得分:1)

SELECT s.*,v.*
FROM softwares s LEFT JOIN versions v ON s.SoftId = v.SoftId
WHERE DateAdded IS NULL
    OR DateAdded = (
        SELECT MAX(DateAdded)
        FROM versions v2
        WHERE v2.SoftId = s.SoftId
    )

https://www.db-fiddle.com/f/bNYJL5eobFYP3TRukA1Wi7/0