Gurux talabasi Qambaraliyev Ahliddin 2-deadline


Har bir talaba o’ziga berilgan predmet soha mavzusi bo’yicha murakkab so’rovlar yaratishi va natijasi bilan ko’rsatib o’tishi kerak


Download 73.76 Kb.
bet6/6
Sana02.06.2024
Hajmi73.76 Kb.
#1835492
1   2   3   4   5   6
Bog'liq
Ahliddin baza

Har bir talaba o’ziga berilgan predmet soha mavzusi bo’yicha murakkab so’rovlar yaratishi va natijasi bilan ko’rsatib o’tishi kerak.

mysql> select*from bazalar where id=any


-> (select id from qismlar);
+------+---------------+----------------------+--------------+
| id | bazaning_nomi | geografik_joylashuvi | qismlar_soni |
+------+---------------+----------------------+--------------+
| 1 | Harbiy | Kaspiy dengizi | 20 |
| 2 | Istisodiy | Orta yer dengizi | 15 |
| 3 | Siyosiy | Arabiston dengizi | 18 |
+------+---------------+----------------------+--------------+
3 rows in set (0.11 sec)

mysql> select*from bazalar where id=all


-> (select id from qismlar);
Empty set (0.08 sec)

mysql> select*from bazalar where !id=all


-> (select id from qismlar);
Empty set, 1 warning (0.00 sec)

mysql>


  1. Har bir talaba o’ziga berilgan predmet soha mavzusi bo’yicha JOIN operatorilaridan foydalanib so’rovlar yaratishi va natijasi bilan ko’rsatib o’tishi kerak.

mysql> select * from qismlar;
+------+---------------+-------------+----------------+-------------+
| id | parcha_raqami | filo_bazasi | joylashgan_joy | harbiy_qism |
+------+---------------+-------------+----------------+-------------+
| 1 | 12 | Harbiy | Karib dengizi | 20-qism |
| 2 | 13 | Jangovar | Bering dengizi | 21-qism |
| 3 | 14 | Maxsus qism | Sharqiy dengiz | 22-qism |
+------+---------------+-------------+----------------+-------------+
3 rows in set (0.00 sec)

mysql> select * from bazalar;


+------+---------------+----------------------+--------------+
| id | bazaning_nomi | geografik_joylashuvi | qismlar_soni |
+------+---------------+----------------------+--------------+
| 1 | Harbiy | Kaspiy dengizi | 20 |
| 2 | Istisodiy | Orta yer dengizi | 15 |
| 3 | Siyosiy | Arabiston dengizi | 18 |
| 4 | Ekalogik | Kara dengizi | 25 |
+------+---------------+----------------------+--------------+
4 rows in set (0.00 sec)

mysql> insert into qismlar


-> values ('4','15','Harbiy','Kaspiy dengizi','23-qism');
Query OK, 1 row affected (0.15 sec)

mysql> select * from qismlar;


+------+---------------+-------------+----------------+-------------+
| id | parcha_raqami | filo_bazasi | joylashgan_joy | harbiy_qism |
+------+---------------+-------------+----------------+-------------+
| 1 | 12 | Harbiy | Karib dengizi | 20-qism |
| 2 | 13 | Jangovar | Bering dengizi | 21-qism |
| 3 | 14 | Maxsus qism | Sharqiy dengiz | 22-qism |
| 4 | 15 | Harbiy | Kaspiy dengizi | 23-qism |
+------+---------------+-------------+----------------+-------------+
4 rows in set (0.00 sec)
mysql> select b.bazaning_nomi,q.joylashgan_joy,q.parcha_raqami,q.harbiy_qism from bazalar b
-> inner join qismlar q
-> on b.id=q.id;
+---------------+----------------+---------------+-------------+
| bazaning_nomi | joylashgan_joy | parcha_raqami | harbiy_qism |
+---------------+----------------+---------------+-------------+
| Harbiy | Karib dengizi | 12 | 20-qism |
| Istisodiy | Bering dengizi | 13 | 21-qism |
| Siyosiy | Sharqiy dengiz | 14 | 22-qism |
| Ekalogik | Kaspiy dengizi | 15 | 23-qism |
+---------------+----------------+---------------+-------------+
4 rows in set (0.00 sec)

mysql>
Download 73.76 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




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