Vous êtes sur la page 1sur 12

| Kota | varchar(20) | NO | | NULL | |

+---------------+-------------+------+-----+---------+-------+

5 rows in set (0.12 sec)

MariaDB [universitas]> insert into pegawai (NIP, Nama_Depan, Nama_Belakang,

-> Alamat, Kota) values ('132061046',

-> 'ANGGUN',

-> 'NURUL',

-> 'JAWA II No. 12',

-> 'BONDOWOSO');

Query OK, 1 row affected (0.46 sec)

MariaDB [universitas]> insert into pegawai values (

-> '132061063',

-> 'NINIK',

-> 'ANDRIYANTI',

-> 'KALIMANTAN V No. 5',

-> 'JAKARTA');

Query OK, 1 row affected (0.07 sec)

MariaDB [universitas]> insert into mahasiswa values (

-> '132061119',

-> 'KHURIN',

-> 'KHINATA',

-> 'MASTRIP II No. 9',


-> 'MEDAN');

Query OK, 1 row affected (0.22 sec)

MariaDB [universitas]> insert into mahasiswa values (

-> '132061127',

-> 'INDAH',

-> 'APRILIANI',

-> 'JL. SADEWA XII No. 4',

-> 'JAKARTA');

Query OK, 1 row affected (0.06 sec)

MariaDB [universitas]> select * from pegawai;

+-----------+------------+---------------+--------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+--------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

+-----------+------------+---------------+--------------------+-----------+

2 rows in set (0.00 sec)

MariaDB [universitas]>

MariaDB [universitas]> select * from pegawai;

+-----------+------------+---------------+--------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+--------------------+-----------+
| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

+-----------+------------+---------------+--------------------+-----------+

2 rows in set (0.00 sec)

MariaDB [universitas]> insert into pegawai values (

-> '132061119',

-> 'KHURIN',

-> 'KHINATA',

-> 'JL. MASTRIP II No. 9',

-> 'MEDAN');

Query OK, 1 row affected (0.05 sec)

MariaDB [universitas]> insert into pegawai values (

-> '132061127',

-> 'INDAH',

-> 'APRILIANI',

-> 'JL. SADEWA XII No. 4',

-> 'JAKARTA');

Query OK, 1 row affected (0.05 sec)

MariaDB [universitas]> select * from pegawai;

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+
| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

+-----------+------------+---------------+----------------------+-----------+

4 rows in set (0.00 sec)

MariaDB [universitas]> select * from mahasiswa order by nama_depan and nama_bela

kang asc;

ERROR 1054 (42S22): Unknown column 'nama_depan' in 'order clause'

MariaDB [universitas]> select * from pegawai order by nama_depan and nama_belaka

ng asc;

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

+-----------+------------+---------------+----------------------+-----------+

4 rows in set, 4 warnings (0.17 sec)

MariaDB [universitas]> select nama_depan and nama_belakang from pegawai asc;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MariaDB server version for the right syntax to use near 'asc
' at line 1

MariaDB [universitas]> select nama_depan and nama_belakang from pegawai;

+------------------------------+

| nama_depan and nama_belakang |

+------------------------------+

| 0|

| 0|

| 0|

| 0|

+------------------------------+

4 rows in set, 4 warnings (0.00 sec)

MariaDB [universitas]> select nama_depan from pegawai;

+------------+

| nama_depan |

+------------+

| ANGGUN |

| NINIK |

| KHURIN |

| INDAH |

+------------+

4 rows in set (0.01 sec)

MariaDB [universitas]> select Nama_Depan, Nama_Belakang from pegawai order by Na

ma_Depan asc;
+------------+---------------+

| Nama_Depan | Nama_Belakang |

+------------+---------------+

| ANGGUN | NURUL |

| INDAH | APRILIANI |

| KHURIN | KHINATA |

| NINIK | ANDRIYANTI |

+------------+---------------+

4 rows in set (0.00 sec)

MariaDB [universitas]> Ctrl-C -- exit!

Bye

C:\xampp\mysql\bin>mysql -u root

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 3

Server version: 10.1.35-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use universitas

Database changed

MariaDB [universitas]> desc pegawai;


+---------------+-------------+------+-----+---------+-------+

| Field | Type | Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+

| NIP | char(9) | NO | PRI | NULL | |

| Nama_Depan | varchar(30) | NO | | NULL | |

| Nama_Belakang | varchar(30) | NO | | NULL | |

| Alamat | varchar(40) | NO | | NULL | |

| Kota | varchar(20) | NO | | NULL | |

+---------------+-------------+------+-----+---------+-------+

5 rows in set (0.06 sec)

MariaDB [universitas]> select * from pegawai;

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

+-----------+------------+---------------+----------------------+-----------+

4 rows in set (0.00 sec)

MariaDB [universitas]> select distinct kota from pegawai;

+-----------+

| kota |
+-----------+

| BONDOWOSO |

| JAKARTA |

| MEDAN |

+-----------+

3 rows in set (0.07 sec)

MariaDB [universitas]> select * from pegawai where right(Nama_Depan)='N';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MariaDB server version for the right syntax to use near ')='

N'' at line 1

MariaDB [universitas]> select * from pegawai where right(Nama_Depan)='n';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MariaDB server version for the right syntax to use near ')='

n'' at line 1

MariaDB [universitas]> select * from pegawai where right(Nama_Depan,1)='N';

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

+-----------+------------+---------------+----------------------+-----------+

2 rows in set (0.06 sec)

MariaDB [universitas]> select * from pegawai where left(Nama_Belakang,1)-'A';


Empty set, 8 warnings (0.06 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang like -'A%';

Empty set, 3 warnings (0.00 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang like '-A%';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang like 'A%';

+-----------+------------+---------------+----------------------+---------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+---------+

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

+-----------+------------+---------------+----------------------+---------+

2 rows in set (0.00 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang -like 'A%';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that

corresponds to your MariaDB server version for the right syntax to use near 'lik

e 'A%'' at line 1

MariaDB [universitas]> select * from pegawai where Nama_Belakang like '-A';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang like 'A-';


Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where Nama_Belakang not like 'A%';

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

+-----------+------------+---------------+----------------------+-----------+

2 rows in set (0.00 sec)

MariaDB [universitas]> select NIP from pegawai where kota='JAKARTA' or

-> kota='MEDAN';

+-----------+

| NIP |

+-----------+

| 132061063 |

| 132061119 |

| 132061127 |

+-----------+

3 rows in set (0.07 sec)

MariaDB [universitas]> select * from pegawai where kota='Jember'

-> ;

Empty set (0.00 sec)


MariaDB [universitas]> select * from pegawai where kota='Jember';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai order by Nama_Belakang asc;

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

+-----------+------------+---------------+----------------------+-----------+

4 rows in set (0.00 sec)

MariaDB [universitas]> select * from pegawai where NIP like '131';

Empty set (0.09 sec)

MariaDB [universitas]> select * from pegawai where Nama_Depan like 'k%';

+-----------+------------+---------------+----------------------+-------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-------+

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

+-----------+------------+---------------+----------------------+-------+

1 row in set (0.00 sec)


MariaDB [universitas]> select * from pegawai where NIP like '130';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where NIP like '132';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where NIP like '132%';

+-----------+------------+---------------+----------------------+-----------+

| NIP | Nama_Depan | Nama_Belakang | Alamat | Kota |

+-----------+------------+---------------+----------------------+-----------+

| 132061046 | ANGGUN | NURUL | JAWA II No. 12 | BONDOWOSO |

| 132061063 | NINIK | ANDRIYANTI | KALIMANTAN V No. 5 | JAKARTA |

| 132061119 | KHURIN | KHINATA | JL. MASTRIP II No. 9 | MEDAN |

| 132061127 | INDAH | APRILIANI | JL. SADEWA XII No. 4 | JAKARTA |

+-----------+------------+---------------+----------------------+-----------+

4 rows in set (0.04 sec)

MariaDB [universitas]> select * from pegawai where NIP like '131%';

Empty set (0.00 sec)

MariaDB [universitas]> select * from pegawai where NIP like '130%';

Empty set (0.01 sec)

MariaDB [universitas]>