下面的查詢在MySQL中成功執行,但在MSSQL中引發錯誤。任何人都可以爲我提供一個MSSQL 2008中等效查詢的例子嗎?MSSQL中的等效SQL查詢
SELECT DISTINCT TOP 20
[users].[id], [users].[email], [users].[first_name], [users].[last_name],
(SELECT groups_groups.name
FROM users AS groups_users
LEFT JOIN users_groups AS groups_users_groups ON groups_users_groups.user_id = groups_users.id
LEFT JOIN groups AS groups_groups ON groups_groups.id = groups_users_groups.group_id
WHERE users.id = groups_users_groups.user_id) AS [groups]
FROM [users] GROUP BY [users].[id], [users].[email], [users].[first_name], [users].[last_name]
ORDER BY [users].[id] DESC
錯誤:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
您收到什麼錯誤消息? – CloudyMarble
我非常懷疑你的開頭語句的真實性 – Strawberry
MySQL現在知道'TOP'了嗎? – DrCopyPaste