PERINTAH QUERY SELECT LIKE (PENCARIAN)
PERINTAH QUERY SELECT LIKE (PENCARIAN) DI CMD
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\EDI SANTOSO>cd/xampp/mysql/bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use database_penjualan;
Database changed
mysql> show tables;
+------------------------------+
| Tables_in_database_penjualan |
+------------------------------+
| barang |
| customer |
| detail_transaksi |
| jenis |
| lokasi |
| petugas |
| satuan |
| supplier |
| transaksi |
+------------------------------+
9 rows in set (0.00 sec)
PERINTAH MENAMPILKAN SEMUA FIELD & RECORD DARI TABEL BARANG
mysql> select * from barang;
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
| br02 | lifeboy | sp02 | 2 | 300 | s02 | l02 | 3000 |
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
5 rows in set (0.00 sec)
PERINTAH MENAMPILKAN YANG BERAHIR HURUF 'SO'
mysql> select * from barang
-> where nama_barang like '%so';
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN YANG BERAWAL HURUF 'C'
mysql> select * from barang
-> where nama_barang like 'c%';
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN YANG MENGANDUNG HURUF 'A'
mysql> select * from barang
-> where nama_barang like '%a%';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
3 rows in set (0.00 sec)
PERINTAH MENAMPILKAN BEBERAPA FIELD DARI TABLE BARANG
mysql> select kode_barang,nama_barang,stock,kode_satuan from barang;
+-------------+----------------+-------+-------------+
| kode_barang | nama_barang | stock | kode_satuan |
+-------------+----------------+-------+-------------+
| br01 | rinso | 200 | s01 |
| br02 | lifeboy | 300 | s02 |
| br03 | sampoerna mild | 700 | s03 |
| br04 | tropical | 500 | s04 |
| br05 | clear | 400 | s05 |
+-------------+----------------+-------+-------------+
5 rows in set (0.00 sec)
PERINTAH MENAMPILKAN 1 RECORD DENGAN MENGGUNAKAN KONDISI
mysql> select * from barang
-> where kode_barang='br03';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN SEMUA FIELD DARI TABEL BARANG,,DENGAN NAMA FIELD YANG MENYERUPAI 'b';
mysql> select * from barang
-> where kode_barang like'%b%';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
| br02 | lifeboy | sp02 | 2 | 300 | s02 | l02 | 3000 |
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
5 rows in set (0.00 sec)
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\EDI SANTOSO>cd/xampp/mysql/bin
C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 50
Server version: 5.5.8 MySQL Community Server (GPL)
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use database_penjualan;
Database changed
mysql> show tables;
+------------------------------+
| Tables_in_database_penjualan |
+------------------------------+
| barang |
| customer |
| detail_transaksi |
| jenis |
| lokasi |
| petugas |
| satuan |
| supplier |
| transaksi |
+------------------------------+
9 rows in set (0.00 sec)
PERINTAH MENAMPILKAN SEMUA FIELD & RECORD DARI TABEL BARANG
mysql> select * from barang;
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
| br02 | lifeboy | sp02 | 2 | 300 | s02 | l02 | 3000 |
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
5 rows in set (0.00 sec)
PERINTAH MENAMPILKAN YANG BERAHIR HURUF 'SO'
mysql> select * from barang
-> where nama_barang like '%so';
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN YANG BERAWAL HURUF 'C'
mysql> select * from barang
-> where nama_barang like 'c%';
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+-------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN YANG MENGANDUNG HURUF 'A'
mysql> select * from barang
-> where nama_barang like '%a%';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
3 rows in set (0.00 sec)
PERINTAH MENAMPILKAN BEBERAPA FIELD DARI TABLE BARANG
mysql> select kode_barang,nama_barang,stock,kode_satuan from barang;
+-------------+----------------+-------+-------------+
| kode_barang | nama_barang | stock | kode_satuan |
+-------------+----------------+-------+-------------+
| br01 | rinso | 200 | s01 |
| br02 | lifeboy | 300 | s02 |
| br03 | sampoerna mild | 700 | s03 |
| br04 | tropical | 500 | s04 |
| br05 | clear | 400 | s05 |
+-------------+----------------+-------+-------------+
5 rows in set (0.00 sec)
PERINTAH MENAMPILKAN 1 RECORD DENGAN MENGGUNAKAN KONDISI
mysql> select * from barang
-> where kode_barang='br03';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
1 row in set (0.00 sec)
PERINTAH MENAMPILKAN SEMUA FIELD DARI TABEL BARANG,,DENGAN NAMA FIELD YANG MENYERUPAI 'b';
mysql> select * from barang
-> where kode_barang like'%b%';
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| kode_barang | nama_barang | kode_supplier | kode_jenis | stock | kode_satuan | kode_lokasi | harga |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
| br01 | rinso | sp01 | 1 | 200 | s01 | l01 | 2000 |
| br02 | lifeboy | sp02 | 2 | 300 | s02 | l02 | 3000 |
| br03 | sampoerna mild | sp03 | 3 | 700 | s03 | l03 | 15000 |
| br04 | tropical | sp04 | 4 | 500 | s04 | l04 | 20000 |
| br05 | clear | sp05 | 5 | 400 | s05 | l05 | 2000 |
+-------------+----------------+---------------+------------+-------+-------------+-------------+-------+
5 rows in set (0.00 sec)
Komentar
Posting Komentar