我必须从有限的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”的“所有”列,然后从“表版本”中选择“最新版本”。 谢谢
答案 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
)