0
我試圖用我的UNION
的組合ORDER BY
表達,我收到錯誤ORDER BY的應用ORDER BY到UNION MYSQL
「表達式#1包含聚合函數,並適用於聯盟」。
(SELECT 'SELECT' AS argument, count(argument) FROM mysql.general_log WHERE
argument LIKE ("SELECT%"))
UNION
(SELECT 'INSERT' AS argument, count(argument) FROM mysql.general_log WHERE
argument LIKE ("INSERT%"))
UNION
(SELECT 'UPDATE' AS argument, count(argument) FROM mysql.general_log WHERE
argument LIKE ("UPDATE%"))
UNION
(SELECT 'DELETE' AS argument, count(argument) FROM mysql.general_log WHERE
argument LIKE ("DELETE%"))
ORDER BY count(argument) ASC;
嗨,我迎接錯誤「每個派生表必須有它自己的別名」 – Sailthor
感謝,但類似的錯誤「ORDER BY的表達式1包含聚合函數並適用於非聚合查詢的結果」 – Sailthor
這樣做工作,非常感謝。爲什麼MySql要求我們使用這個別名? – Sailthor