Amaliy mashg’ulotlarida berilgan topshiriqlar


RIGHT JOIN table_2 USING (column_name)


Download 395.12 Kb.
bet17/20
Sana15.11.2023
Hajmi395.12 Kb.
#1777301
1   ...   12   13   14   15   16   17   18   19   20
Bog'liq
SQL command 29-11-2021

RIGHT JOIN table_2 USING (column_name);
SELECT column_list
FROM table_1
RIGHT JOIN table_2 USING (column_name)
W HERE column_table_1 IS NULL;
SELECT
m.member_id,
m.name AS member,
c.committee_id,
c.name AS committee
FROM
members m
RIGHT JOIN committees c on c.name = m.name;


| member_id | member | committee_id | committee |
+-----------+--------+--------------+-----------+
| 1 | John | 1 | John |
| 3 | Mary | 2 | Mary |
| 5 | Amelia | 3 | Amelia |
| NULL | NULL | 4 | Joe |
+-----------+--------+--------------+-----------+
4 rows in set (0.00 sec)


SELECT
m.member_id,
m.name AS member,
c.committee_id,
c.name AS committee
FROM
members m
RIGHT JOIN committees c USING(name);


committee a’zolarini members jadvalida bo'lmagan a'zolarini topish uchun ushbu so'rovdan foydalanish mumkin:


T o find the committee members who are not in the members table, you use this query:


SELECT
m.member_id,
m.name AS member,
c.committee_id,
c.name AS committee
FROM
members m
RIGHT JOIN committees c USING(name)
WHERE m.member_id IS NULL;


+-----------+--------+--------------+-----------+
| member_id | member | committee_id | committee |
+-----------+--------+--------------+-----------+
| NULL | NULL | 4 | Joe |
+-----------+--------+--------------+-----------+
1 row in set (0.00 sec)


Download 395.12 Kb.

Do'stlaringiz bilan baham:
1   ...   12   13   14   15   16   17   18   19   20




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling