Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

mysql> desc barang;

+---------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| kd_brg | varchar(15) | NO | PRI | NULL | |
| nm_brg | varchar(25) | YES | | NULL | |
| harga | int(25) | YES | | NULL | |
| jml_brg | int(25) | YES | | NULL | |
| nm_supp | varchar(25) | YES | | NULL | |
+---------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

mysql> insert into barang values


-> ('1','computer','3400000','2','Pt. Devi Maresyah'),
-> ('2','UPS','3400000','2','Pt. Devi Maresyah);
'> ,;
'> ';
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 '' at
line 3
mysql> insert into barang values
-> ('1','computer','3400000','2','Pt. Abadi karya'),
-> ('2','UPS','3400000','2','Pt. sentosa karya'),
-> ('3','printer','3000000','3','CV Cemerlang'),
-> ('4','printer MPX','3450000','3','CV andi karya U');
Query OK, 4 rows affected (0.06 sec)
Records: 4 Duplicates: 0 Warnings: 0

mysql> select nm_brg, nm_supp from barang


-> where nm_brg like 'p%';
+-------------+-----------------+
| nm_brg | nm_supp |
+-------------+-----------------+
| printer | CV Cemerlang |
| printer MPX | CV andi karya U |
+-------------+-----------------+
2 rows in set (0.00 sec)

mysql> select nm_brg, nm_supp from barang


-> where nm_brg like 'p%' and nm_supp like '%a';
Empty set (0.00 sec)

mysql> select nm_brg, nm_supp from barang


-> where nm_brg like 'p%' or nm_supp like '%a';
+-------------+-------------------+
| nm_brg | nm_supp |
+-------------+-------------------+
| computer | Pt. Abadi karya |
| UPS | Pt. sentosa karya |
| printer | CV Cemerlang |
| printer MPX | CV andi karya U |
+-------------+-------------------+
4 rows in set (0.00 sec)

mysql> select nm_brg, nm_supp from barang


-> where nm_brg like '%n%' and nm_supp not like '%u';
+---------+--------------+
| nm_brg | nm_supp |
+---------+--------------+
| printer | CV Cemerlang |
+---------+----------

You might also like