gpt4 book ai didi

sql - 查询子查询

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:13 25 4
gpt4 key购买 nike

我正在尝试做这样的事情:

SELECT t1.*,
t2.*
FROM (SELECT *
FROM USER) AS t1,
(SELECT *
FROM t1) AS t2

它在 MySQL 中不起作用。像上面这样的事情可能吗?我的另一个选择是采用最后一个子查询并将其“包装”在主查询周围。想法?

最佳答案

使用:

SELECT t1.*,
t2.*
FROM (SELECT *
FROM USER) AS t1,
(SELECT *
FROM (SELECT *
FROM USER) AS t1) AS t2

WITH 语法允许您在 CTE 之上构建:

WITH t1 AS (
SELECT * FROM USER), -- comma separates them
t2 AS (
SELECT * FROM t1)
SELECT t1.*, t2.*
FROM t1, t2

..但是 MySQL 不支持 WITH 子句。

关于sql - 查询子查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3463950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com