본문 바로가기
MySql

MySQL에서 두 개의 하위 쿼리 결합

by 베이스 공부 2020. 10. 22.
반응형

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;

오류 1064 (42000) : SQL 구문에 오류가 있습니다. 1 행에서 'join (select * from table1 where id = 2)'근처에서 사용할 올바른 구문은 MySQL 서버 버전에 해당하는 설명서를 확인하십시오.

내 구문이 올바르지 않습니까?

 

해결 방법

 

예제 확인

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

 

참조 페이지 https://stackoverflow.com/questions/4701144

 

 

반응형

댓글