mysql> select a.*, b.* from a inner join b on a.aa = b.ba;
+----+------+------+----+------+------+
| aa | ab | ac | ba | bb | bc |
+----+------+------+----+------+------+
| 1 | 100 | a1 | 1 | 100 | b1 |
| 3 | 300 | a3 | 3 | 300 | b2 |
| 5 | 500 | a5 | 5 | 500 | b3 |
+----+------+------+----+------+------+
3 rows in set (0.00 sec)
mysql> select a.*, b.* from a left outer join b on a.aa = b.ba;
+----+------+------+------+------+------+
| aa | ab | ac | ba | bb | bc |
+----+------+------+------+------+------+
| 1 | 100 | a1 | 1 | 100 | b1 |
| 2 | 200 | a2 | NULL | NULL | NULL |
| 3 | 300 | a3 | 3 | 300 | b2 |
| 4 | 400 | a4 | NULL | NULL | NULL |
| 5 | 500 | a5 | 5 | 500 | b3 |
+----+------+------+------+------+------+
5 rows in set (0.00 sec)
mysql> select a.*, b.* from a left join b on a.aa = b.ba;
+----+------+------+------+------+------+
| aa | ab | ac | ba | bb | bc |
+----+------+------+------+------+------+
| 1 | 100 | a1 | 1 | 100 | b1 |
| 2 | 200 | a2 | NULL | NULL | NULL |
| 3 | 300 | a3 | 3 | 300 | b2 |
| 4 | 400 | a4 | NULL | NULL | NULL |
| 5 | 500 | a5 | 5 | 500 | b3 |
+----+------+------+------+------+------+
5 rows in set (0.00 sec)
'Database > Mysql' 카테고리의 다른 글
Joing 방법 종류 정리 (0) | 2009.02.11 |
---|---|
insert... select (0) | 2009.02.11 |
sql 기본 query insert (0) | 2009.02.11 |
어제, 오늘 날짜 구하기 (0) | 2009.02.11 |
mysql 어제 날짜 구하기 (2) | 2009.02.11 |