Detailed explanation of MySQL WITH clause
MySQL's WITH clause allows a named temporary result set to be defined in a query. Although this feature is supported by other relational database management systems (RDBMS), such as Oracle and Microsoft SQL Server, MySQL has not been supported historically.
A user recently encountered this restriction when trying to create a view using a WITH clause:
WITH authorRating(aname, rating) AS
SELECT aname, AVG(quantity)
FROM book
GROUP BY aname
MySQL 8.0 update
WITH clause was not supported in MySQL versions prior to 8.0, but MySQL 8.0 eventually introduced common table expressions (CTEs), including recursive CTEs. This feature is a welcome addition to keep MySQL consistent with other RDBMSs.
MySQL version before 8.0
]Before MySQL 8.0, there was no method to directly use the WITH clause in MySQL. This feature has been around as a requested feature since 2006.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3