如何在“from”别名上加入 table?
How to join table on ‘from’ alias?
我怎么能做这样的事情?
select * from (generating table) alias_table
left join (select * from alias_table where id>5) alias_table_2
on alias_table.id=alias_table_2.id
如果您的 MySQL 版本不早于 8,那么您可以使用如下常用的 table 表达式:
WITH alias_table (column_list from generated table) AS (
generating table
)
select * from alias_table
left join (select * from alias_table where id>5) alias_table_2
on alias_table.id=alias_table_2.id
在下面 link 你会找到一个有效的例子:
https://www.db-fiddle.com/#&togetherjs=2GJBwJNocB
我怎么能做这样的事情?
select * from (generating table) alias_table
left join (select * from alias_table where id>5) alias_table_2
on alias_table.id=alias_table_2.id
如果您的 MySQL 版本不早于 8,那么您可以使用如下常用的 table 表达式:
WITH alias_table (column_list from generated table) AS (
generating table
)
select * from alias_table
left join (select * from alias_table where id>5) alias_table_2
on alias_table.id=alias_table_2.id
在下面 link 你会找到一个有效的例子: https://www.db-fiddle.com/#&togetherjs=2GJBwJNocB