여러 속성을 하나의 테이블에 표시 할 수 있도록 여러 공통 속성에서 조인해야하는 배수 테이블이 있습니다.분리형 행이있는 공통 속성에 대해 여러 테이블을 결합하는 경우
내가 뭘
+--------+---------+-------+--------+
| make | model | year | kms |
+--------+---------+-------+--------+
| toyota | corolla | 1999 | 25000 |
| toyota | camry | 2002 | 50000 |
+--------+---------+-------+--------+
표 2
+--------+---------+-------+---------+
| make | model | year | mileage |
+--------+---------+-------+---------+
| toyota | corolla | 1999 | 20 |
| toyota | qualis | 2004 | 25 |
+--------+---------+-------+---------+
표 3
+--------+----------+-------+-------+
| make | model | year | color |
+--------+----------+-------+-------+
| toyota | camry | 2002 | blue |
| toyota | rav4 | 2006 | green |
+--------+----------+-------+-------+
표하여 결과에 가입하려면 다음
select
* from table1 as a
full join table2 as b
using (make, model, year)
full join table3 as c
using (make, model, year)
필요한 것은 아래 표와 같습니다.
+--------+---------+-------+-------+----------+--------+
| make | model | year | kms | mileage | color |
+--------+---------+-------+-------+----------+--------+
| toyota | corolla | 1999 | 25000 | 20 | |
| toyota | camry | 2002 | 50000 | | blue |
| toyota | qualis | 2004 | | 25 | |
| toyota | rav4 | 2006 | | | green |
+--------+---------+-------+-------+----------+--------+
그러나 일부 결과는 make,model,year
과 중복되어 일부 행에 중복됩니다.
필요한 것을 얻으려면 어떻게해야합니까? 실제 데이터 세트의 경우, 테이블 당 5 common attributes
, 테이블 당 약 20-40 different attributes
이 있습니다.
본능은 'USING'에 의존하지 않고 전체 조인 구문을 사용하여 테스트하는 것입니다. –