| id | Nomi | id | Izoh |
+----+-------+----+-------------+
| 1 | Kitob | 1 | Badiy kitob |
| 3 | Qalam | 3 | Qizil qalam |
+----+-------+----+-------------+
2 rows in set (0.00 sec)
FULL JOIN
SELECT *
-> FROM tovarlar right JOIN izoh
-> ON tovarlar.ID = izoh.ID
-> union
-> SELECT *
-> FROM tovarlar left JOIN izoh
-> ON tovarlar.ID = izoh.ID;
+------+-------+------+-----------------+
| id | Nomi | id | Izoh |
+------+-------+------+-----------------+
| 1 | Kitob | 1 | Badiy kitob |
| 3 | Qalam | 3 | Qizil qalam |
| NULL | NULL | 5 | Yumshoq ayiqcha |
| 2 | Stul | NULL | NULL |
+------+-------+------+-----------------+
4 rows in set (0.07 sec)
SELECT *
-> FROM tovarlar left JOIN izoh
-> ON tovarlar.ID = izoh.ID
-> union all
-> SELECT *
-> FROM tovarlar right JOIN izoh
-> ON tovarlar.ID = izoh.ID;
+------+-------+------+-----------------+
| id | Nomi | id | Izoh |
+------+-------+------+-----------------+
| 1 | Kitob | 1 | Badiy kitob |
| 3 | Qalam | 3 | Qizil qalam |
| 2 | Stul | NULL | NULL |
| 1 | Kitob | 1 | Badiy kitob |
Do'stlaringiz bilan baham: |