Home >Database >Mysql Tutorial >Does MySQL Support the WITH Clause, and If So, Since When?
Detailed explanation of MySQL WITH clause
MySQL’s WITH clause allows you to define a named temporary result set in a query. While other relational database management systems (RDBMS) such as Oracle and Microsoft SQL Server support this feature, MySQL historically has not.
A user recently encountered this limitation while trying to create a view using the WITH clause:
<code class="language-sql">WITH authorRating(aname, rating) AS SELECT aname, AVG(quantity) FROM book GROUP BY aname</code>
MySQL 8.0 update
With clauses were not supported in MySQL versions prior to 8.0, but MySQL 8.0 finally introduced common table expressions (CTEs), including recursive CTEs. This feature is a welcome addition that brings MySQL into line with other RDBMS.
MySQL versions before 8.0
Before MySQL 8.0, there was no direct way to use the WITH clause in MySQL. This feature has existed as a requested feature since 2006.
The above is the detailed content of Does MySQL Support the WITH Clause, and If So, Since When?. For more information, please follow other related articles on the PHP Chinese website!