Using the WITH clause in an INSERT statement
You will need to place the INSERT INTO right after the CTE. So the code will be: ;WITH alias (y,z) AS ( SELECT y,z FROM tableb ) INSERT INTO tablea(a,b) SELECT y, z FROM alias See SQL Fiddle with Demo
You will need to place the INSERT INTO right after the CTE. So the code will be: ;WITH alias (y,z) AS ( SELECT y,z FROM tableb ) INSERT INTO tablea(a,b) SELECT y, z FROM alias See SQL Fiddle with Demo
MySQL prior to version 8.0 doesn’t support the WITH clause (CTE in SQL Server parlance; Subquery Factoring in Oracle), so you are left with using: TEMPORARY tables DERIVED tables inline views (effectively what the WITH clause represents – they are interchangeable) The request for the feature dates back to 2006. As mentioned, you provided a … Read more
The SQL WITH clause was introduced by Oracle in the Oracle 9i release 2 database. The SQL WITH clause allows you to give a sub-query block a name (a process also called sub-query refactoring), which can be referenced in several places within the main SQL query. The name assigned to the sub-query is treated as … Read more