gpt4 book ai didi

sql - 在 MySQL 中加入两个子查询

转载 作者:IT老高 更新时间:2023-10-29 00:12:40 26 4
gpt4 key购买 nike

我在 MySQL 中的两个联合子查询中遇到问题,例如

(select * from table1 where id = 1 group by f1) a1 
join
(select * from table2 where id = 2 group by f2) a2 ON a1.f3 = a2.f3;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'join (select * from table1 where id = 2)' at line 1

我的语法不正确吗?

最佳答案

查看一些示例

SELECT * FROM table1, table2;

SELECT * FROM table1 INNER JOIN table2 ON table1.id=table2.id;

SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;

SELECT * FROM table1 LEFT JOIN table2 USING (id);

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

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