I've got to execute a self-joining sql statement on a derived table in mysql. The derived table involves a hairy subquery, and I'm wondering if there's any alternative to actually writing and executing it twice-
SELECT a.* FROM (my hairy subquery) AS a
LEFT JOIN (my hairy subquery) AS a2
ON a.groupname = a2.groupname etc..
Run Code Online (Sandbox Code Playgroud)
标准解决方案是使用 CTE,但 MySQL 尚不支持这些。替代方案是:
有关的