在oracle中有没有类似于with关键字的mysql

mkh04yzy  于 2021-06-23  发布在  Mysql
关注(0)|答案(1)|浏览(377)

我正在尝试将一些oraclesql转换为mysql,遇到了 WITH oracle中的关键字。有没有等效的 WITH 在mysql中?谢谢 WITH oracle中的示例:

with cus as (select id from tb_company where id=3)
select * from cus;
7lrncoxx

7lrncoxx1#

是的,自从mysql版本8.0以来,有一个等价的版本:

WITH
  cte1 AS (SELECT a, b FROM table1),
  cte2 AS (SELECT c, d FROM table2)
SELECT b, d FROM cte1 JOIN cte2
 WHERE cte1.a = cte2.c;

https://dev.mysql.com/doc/refman/8.0/en/with.html

相关问题