Show databases; + +


Download 13.11 Kb.
Sana18.12.2022
Hajmi13.11 Kb.
#1030660
Bog'liq
mysql


mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| travel_markazi |
+--------------------+
5 rows in set (0.14 sec)

mysql> use travel_markazi;


Database changed
mysql> show tables;
+--------------------------+
| Tables_in_travel_markazi |
+--------------------------+
| mijozlar |
| turlar |
| yashash_joyi |
| yollanma |
+--------------------------+
4 rows in set (0.08 sec)

mysql> show table mijozlar;


ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mijozlar' at line 1
mysql> desc mijozlar;
+---------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+----------+------+-----+---------+-------+
| m_id | int | NO | PRI | NULL | |
| fam | char(40) | NO | | NULL | |
| ism | char(50) | NO | | NULL | |
| sharifi | char(50) | NO | | NULL | |
| passport | char(10) | NO | | NULL | |
| tugilgan_sana | date | YES | | NULL | |
+---------------+----------+------+-----+---------+-------+
6 rows in set (0.03 sec)

mysql> select * from mijozlar;


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
3 rows in set (0.00 sec)

mysql>
mysql>


mysql> select * from mijozlar where m_id='2048378' and passport='AC';
+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
+---------+-----------+---------+----------------+----------+---------------+
1 row in set (0.04 sec)

mysql> select * from mijozlar where not ( m_id='2048378' and passport='AC');


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
2 rows in set (0.11 sec)

mysql> select * from mijozlar where id in(1,2,3);


ERROR 1054 (42S22): Unknown column 'id' in 'where clause'
mysql> select * from mijozlar where m_id in (1,2,3);
Empty set (0.11 sec)

mysql> select * from mijozlar where m_id in (2048378,2333433,8542749);


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
3 rows in set (0.00 sec)

mysql> select fam, sharifi


-> from mijozlar
where m_id between 2048378 and 8542749;
+-----------+----------------+
| fam | sharifi |
+-----------+----------------+
| Aynazarov | Turamurodovich |
| Hamroyev | Utkirovich |
| Aynazarov | Turamurodovich |
+-----------+----------------+
3 rows in set (0.11 sec)

mysql> select * from mijozlar where tugilgan_sana like '20%';


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
3 rows in set (0.11 sec)

mysql> select * from mijozlar where fam like 'A%';


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
2 rows in set (0.00 sec)

mysql> select * from mijozlar order by m_id;


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
3 rows in set (0.00 sec)

mysql> select * from mijozlar group by m_id;


+---------+-----------+---------+----------------+----------+---------------+
| m_id | fam | ism | sharifi | passport | tugilgan_sana |
+---------+-----------+---------+----------------+----------+---------------+
| 2048378 | Aynazarov | Og`abek | Turamurodovich | AC | 2003-11-12 |
| 2333433 | Hamroyev | Javohir | Utkirovich | AB | 2004-04-04 |
| 8542749 | Aynazarov | Ozodbek | Turamurodovich | AAA | 2006-10-10 |
+---------+-----------+---------+----------------+----------+---------------+
3 rows in set (0.00 sec)

mysql> select count(*), m_id,ism from mijozlar group by ism;


+----------+---------+---------+
| count(*) | m_id | ism |
+----------+---------+---------+
| 1 | 2048378 | Og`abek |
| 1 | 2333433 | Javohir |
| 1 | 8542749 | Ozodbek |
+----------+---------+---------+
3 rows in set (0.04 sec)

mysql> select count(*) as passport,fam,m_id from mijozlar group by m_id;


+----------+-----------+---------+
| passport | fam | m_id |
+----------+-----------+---------+
| 1 | Aynazarov | 2048378 |
| 1 | Hamroyev | 2333433 |
| 1 | Aynazarov | 8542749 |
+----------+-----------+---------+
3 rows in set (0.11 sec)

mysql> select count(*) as passport,fam,m_id from mijozlar group by m_id having passport=2;


Empty set (0.11 sec)

mysql> select count(*) as passport,fam,m_id from mijozlar group by m_id having passport=AC;


ERROR 1054 (42S22): Unknown column 'AC' in 'having clause'
mysql> select count(*) as passport,fam,m_id from mijozlar group by m_id having m_id=2;
Empty set (0.00 sec)

mysql> select count(*) as passport,fam,m_id from mijozlar group by m_id having m_id=2048378;


+----------+-----------+---------+
| passport | fam | m_id |
+----------+-----------+---------+
| 1 | Aynazarov | 2048378 |
+----------+-----------+---------+
1 row in set (0.00 sec)

mysql> select * from turlar;


+--------------------------+-----------------------------+----------------------+-------------------+
| ovqat_turi | EU_ASIA_va_Boshqalar | tunash_joyi | tunash_joyi_narxi |
+--------------------------+-----------------------------+----------------------+-------------------+
| suyuq_quyuq_qovurma | Malaziya_Amerika_Afgoniston | yotoqxona_mexmonxona | 9.8 |
| shorva_lagmon_shashlik | Uzbekiston_Russia_Hindiston | hovli_katej | 6.9 |
| mastava_chuponcha_tandir | Xitoy_Shvetsariya_Italiya | mexmonxona_dacha | 10.5 |
+--------------------------+-----------------------------+----------------------+-------------------+
3 rows in set (0.00 sec)
Download 13.11 Kb.

Do'stlaringiz bilan baham:




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