开发者

Join two subquery in MySQL

开发者 https://www.devze.com 2023-02-04 04:38 出处:网络
I am having problem in joint two subqueries in MySQL, e.g. (select * from table1 where id = 1 group by f1) a1

I am having problem in joint two subqueries in MySQL, e.g.

(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

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消