Do I need to repeat subqueries on self-joining in views in mysql-do?

I need to execute a self-signed sql statement in a view in mysql. The resulting table includes a hairy subquery, and I wonder if there is an alternative to writing and running it twice -

SELECT a.* FROM (my hairy subquery) AS a LEFT JOIN (my hairy subquery) AS a2 ON a.groupname = a2.groupname etc.. 
+4
source share
1 answer

The standard solution to this is to use CTE, but they are not yet supported in MySQL. Alternatives:

  • You can put your subquery in the view and join the view yourself.
  • You can create a temporary table and populate it with the results of your subquery.

Similar

+2
source

All Articles