gpt4 book ai didi

mysql - MySQL 中的 WITH 子句?

转载 作者:可可西里 更新时间:2023-11-01 07:35:31 26 4
gpt4 key购买 nike

MySQL是否支持普通表表达式?例如在 Oracle 中有 WITH 子句? :

WITH aliasname
AS
( SELECT COUNT(*) FROM table_name )
SELECT COUNT(*) FROM dept,aliasname

最佳答案

SELECT t.name,
t.num
FROM TABLE t
JOIN (SELECT c.id,COUNT(*) 'num1'
FROM TABLE1 c
WHERE c.column = 'a'
GROUP BY c.id) ta1 ON ta1.id = t.id
JOIN (SELECT d.id,COUNT(*) 'num2'
FROM TABLE2 d
WHERE d.column = 'a'
GROUP BY d.id) ta2 ON ta2.id = t.id

关于mysql - MySQL 中的 WITH 子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14748185/

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