0% found this document useful (0 votes)
22 views2 pages

54485457

The document shows SQL commands used to describe, insert, and select data from a MySQL database table called 'barang'. The table contains fields for product codes, names, prices, quantities, and supplier names. Records are inserted and selected where the product name contains certain letters or the supplier name does not contain certain letters.

Uploaded by

devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

54485457

The document shows SQL commands used to describe, insert, and select data from a MySQL database table called 'barang'. The table contains fields for product codes, names, prices, quantities, and supplier names. Records are inserted and selected where the product name contains certain letters or the supplier name does not contain certain letters.

Uploaded by

devi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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