[英]Join two subquery in MySQL
I am having problem in joint two subqueries in MySQL, eg 我在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; 错误1064(42000):您的SQL语法有错误; 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 查看与您的MySQL服务器版本对应的手册,以便在第1行'join(select * from table1 where id = 2)'附近使用正确的语法
Is my syntax incorrect? 我的语法不正确吗?
Check out some examples 看看一些例子
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.