You are on page 1of 6

Microsoft Windows [Version 6.1.

7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\user>e:
E:\>cd xampp167\mysql\bin
E:\xampp167\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.0.51b-community MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use perpustakaan
Database changed
mysql> select * from buku;
+-----------+----------------+------------+---------------+
| KODE_BUKU | KODE_PENGARANG | JUDUL_BUKU | KODE_PENERBIT |
+-----------+----------------+------------+---------------+
| B0001
| P0001
| P.WEB
| A
|
| B0002
| P0001
| P.B.O
| A
|
| B0003
| P0002
| AGAMA
| B
|
| B0004
| P0004
| KALKULUS | C
|
| B0005
| P0009
| JHJGH
| D
|
+-----------+----------------+------------+---------------+
5 rows in set (0.17 sec)
mysql> select * from pengarang;
+----------------+----------------+--------+--------+
| KODE_PENGARANG | NAMA_PENGARANG | ALAMAT | KOTA |
+----------------+----------------+--------+--------+
| P0001
| ZAINUL
| GRESIK | GRESIK |
| P0002
| LUKMAN
| GRESIK | GRESIK |
| P0004
| HADI
| GRESIK | GRESIK |
| P0005
| LUKMAN
| GRESIK | GRESIK |
+----------------+----------------+--------+--------+
4 rows in set (0.07 sec)
mysql> select * from buku inner join pengarang on(buku.kode_pengarang = pengaran
g.kode_pengarang);
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| KODE_BUKU | KODE_PENGARANG | JUDUL_BUKU | KODE_PENERBIT | KODE_PENGARANG | NAM
A_PENGARANG | ALAMAT | KOTA |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| B0001
| P0001
| P.WEB
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0002
| P0001
| P.B.O
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0003
| P0002
| AGAMA
| B
| P0002
| LUK
MAN
| GRESIK | GRESIK |
| B0004
| P0004
| KALKULUS | C
| P0004
| HAD
I
| GRESIK | GRESIK |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
4 rows in set (0.12 sec)
mysql> select * from buku left join pengarang on(buku.kode_pengarang = pengarang

.kode_pengarang);
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| KODE_BUKU | KODE_PENGARANG | JUDUL_BUKU | KODE_PENERBIT | KODE_PENGARANG | NAM
A_PENGARANG | ALAMAT | KOTA |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| B0001
| P0001
| P.WEB
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0002
| P0001
| P.B.O
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0003
| P0002
| AGAMA
| B
| P0002
| LUK
MAN
| GRESIK | GRESIK |
| B0004
| P0004
| KALKULUS | C
| P0004
| HAD
I
| GRESIK | GRESIK |
| B0005
| P0009
| JHJGH
| D
| NULL
| NUL
L
| NULL | NULL |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
5 rows in set (0.10 sec)
mysql> select * from buku right join pengarang on(buku.kode_pengarang = pengaran
g.kode_pengarang);
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| KODE_BUKU | KODE_PENGARANG | JUDUL_BUKU | KODE_PENERBIT | KODE_PENGARANG | NAM
A_PENGARANG | ALAMAT | KOTA |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
| B0001
| P0001
| P.WEB
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0002
| P0001
| P.B.O
| A
| P0001
| ZAI
NUL
| GRESIK | GRESIK |
| B0003
| P0002
| AGAMA
| B
| P0002
| LUK
MAN
| GRESIK | GRESIK |
| B0004
| P0004
| KALKULUS | C
| P0004
| HAD
I
| GRESIK | GRESIK |
| NULL
| NULL
| NULL
| NULL
| P0005
| LUK
MAN
| GRESIK | GRESIK |
+-----------+----------------+------------+---------------+----------------+---------------+--------+--------+
5 rows in set (0.03 sec)
mysql> select * from pinjam;
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
| ID_PINJAM | NOMOR_SERI | NOMOR_ANGGOTA | NIP_PEG
| TGL_PINJAM | TGL_HARUS_K
EMBALI | TGL_KEMBALI | DENDA | STATUS |
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
|
1 | PERPUS0002 | A000000002
| P000000001 | 2011-12-23 | 2011-12-30
| NULL
| 500 |
1 |
|
2 | PERPUS0001 | A000000003
| P000000002 | 2011-12-23 | 2011-12-30
| NULL
| 1500 |
1 |
|
3 | PERPUS0003 | A000000004
| P000000001 | 2011-12-28 | 2012-01-04
| NULL
| 500 |
1 |
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
3 rows in set (0.09 sec)

mysql> select a.id_pinjam, a.nomor_seri, a.nomor_anggota, b.nama_anggota, a.nip_


peg, a.tgl_pinjam, a.denda
-> from pinjam a inner join anggota b on(a.nomor_anggota = b.nomor_anggota);
+-----------+------------+---------------+--------------+------------+-----------+-------+
| id_pinjam | nomor_seri | nomor_anggota | nama_anggota | nip_peg
| tgl_pinja
m | denda |
+-----------+------------+---------------+--------------+------------+-----------+-------+
|
1 | PERPUS0002 | A000000002
| HILMAN
| P000000001 | 2011-12-2
3 | 500 |
|
2 | PERPUS0001 | A000000003
| ANDIK
| P000000002 | 2011-12-2
3 | 1500 |
|
3 | PERPUS0003 | A000000004
| ANDIKA
| P000000001 | 2011-12-2
8 | 500 |
+-----------+------------+---------------+--------------+------------+-----------+-------+
3 rows in set (0.05 sec)
mysql> select * from pegawai;
+------------+----------+----------+------+------------+
| NIP_PEG
| PASSWORD | NAMA_PEG | JK | ALAMAT_PEG |
+------------+----------+----------+------+------------+
| P000000001 | 123456 | LUKMAN |
0 | GRESIK
|
| P000000002 | 237282 | KAKA
|
0 | GRESIK
|
+------------+----------+----------+------+------------+
2 rows in set (0.05 sec)
mysql> select a.id_pinjam, a.nomor_seri, a.nomor_anggota, b.nama_anggota, a.nip_
peg, a.tgl_pinjam, a.denda
-> from pinjam a inner join anggota b on(a.nomor_anggota = b.nomor_anggota)
-> inner join pegawai on(a.nip_peg = pegawai.nip_peg);
+-----------+------------+---------------+--------------+------------+-----------+-------+
| id_pinjam | nomor_seri | nomor_anggota | nama_anggota | nip_peg
| tgl_pinja
m | denda |
+-----------+------------+---------------+--------------+------------+-----------+-------+
|
1 | PERPUS0002 | A000000002
| HILMAN
| P000000001 | 2011-12-2
3 | 500 |
|
2 | PERPUS0001 | A000000003
| ANDIK
| P000000002 | 2011-12-2
3 | 1500 |
|
3 | PERPUS0003 | A000000004
| ANDIKA
| P000000001 | 2011-12-2
8 | 500 |
+-----------+------------+---------------+--------------+------------+-----------+-------+
3 rows in set (0.00 sec)
mysql> select a.id_pinjam, a.nomor_seri, a.nomor_anggota, b.nama_anggota, a.nip_
peg, c.nama_peg, a.tgl_pinjam, a.denda
-> from pinjam a inner join anggota b on(a.nomor_anggota = b.nomor_anggota)
-> inner join pegawai c on(a.nip_peg = c.nip_peg);
+-----------+------------+---------------+--------------+------------+---------+------------+-------+
| id_pinjam | nomor_seri | nomor_anggota | nama_anggota | nip_peg
| nama_peg
| tgl_pinjam | denda |
+-----------+------------+---------------+--------------+------------+---------+------------+-------+
|
1 | PERPUS0002 | A000000002
| HILMAN
| P000000001 | LUKMAN
| 2011-12-23 | 500 |

|
2 | PERPUS0001 | A000000003
| ANDIK
| P000000002 | KAKA
| 2011-12-23 | 1500 |
|
3 | PERPUS0003 | A000000004
| ANDIKA
| P000000001 | LUKMAN
| 2011-12-28 | 500 |
+-----------+------------+---------------+--------------+------------+---------+------------+-------+
3 rows in set (0.03 sec)
mysql> select a.id_pinjam, a.nomor_seri, e.judul_buku, a.nomor_anggota, b.nama_a
nggota, a.nip_peg, c.nama_peg, a.tgl_pinjam, a.denda
-> from pinjam a inner join anggota b on(a.nomor_anggota = b.nomor_anggota)
-> inner join pegawai c on(a.nip_peg = c.nip_peg)
-> inner join koleksi d on(a.nomor_seri = d.nomor_seri)
-> inner join buku e on(d.kode_buku = e.kode_buku);
+-----------+------------+------------+---------------+--------------+-----------+----------+------------+-------+
| id_pinjam | nomor_seri | judul_buku | nomor_anggota | nama_anggota | nip_peg
| nama_peg | tgl_pinjam | denda |
+-----------+------------+------------+---------------+--------------+-----------+----------+------------+-------+
|
1 | PERPUS0002 | P.WEB
| A000000002
| HILMAN
| P00000000
1 | LUKMAN | 2011-12-23 | 500 |
|
2 | PERPUS0001 | P.B.O
| A000000003
| ANDIK
| P00000000
2 | KAKA
| 2011-12-23 | 1500 |
|
3 | PERPUS0003 | AGAMA
| A000000004
| ANDIKA
| P00000000
1 | LUKMAN | 2011-12-28 | 500 |
+-----------+------------+------------+---------------+--------------+-----------+----------+------------+-------+
3 rows in set (0.00 sec)
mysql> select a.id_pinjam, a.nomor_seri, e.judul_buku, f.nama_pengarang, a.nomor
_anggota, b.nama_anggota, a.nip_peg, c.nama_peg, a.tgl_pinjam, a.denda
-> from pinjam a inner join anggota b on(a.nomor_anggota = b.nomor_anggota)
-> inner join pegawai c on(a.nip_peg = c.nip_peg)
-> inner join koleksi d on(a.nomor_seri = d.nomor_seri)
-> inner join buku e on(d.kode_buku = e.kode_buku)
-> inner join pengarang f on(e.kode_pengarang = f.kode_pengarang);
+-----------+------------+------------+----------------+---------------+-------------+------------+----------+------------+-------+
| id_pinjam | nomor_seri | judul_buku | nama_pengarang | nomor_anggota | nama_an
ggota | nip_peg
| nama_peg | tgl_pinjam | denda |
+-----------+------------+------------+----------------+---------------+-------------+------------+----------+------------+-------+
|
1 | PERPUS0002 | P.WEB
| ZAINUL
| A000000002
| HILMAN
| P000000001 | LUKMAN | 2011-12-23 | 500 |
|
2 | PERPUS0001 | P.B.O
| ZAINUL
| A000000003
| ANDIK
| P000000002 | KAKA
| 2011-12-23 | 1500 |
|
3 | PERPUS0003 | AGAMA
| LUKMAN
| A000000004
| ANDIKA
| P000000001 | LUKMAN | 2011-12-28 | 500 |
+-----------+------------+------------+----------------+---------------+-------------+------------+----------+------------+-------+
3 rows in set (0.00 sec)
mysql> select a.nomor_anggota, a.nama_anggota, sum(denda) total_denda
-> from anggota a inner join pinjam b on(a.nomor_anggota = b.nomor_anggota);
ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GR
OUP columns is illegal if there is no GROUP BY clause
mysql> select a.nomor_anggota, a.nama_anggota, sum(denda) total_denda
-> from anggota a inner join pinjam b on(a.nomor_anggota = b.nomor_anggota)

-> group by a.nomor_anggota;


+---------------+--------------+-------------+
| nomor_anggota | nama_anggota | total_denda |
+---------------+--------------+-------------+
| A000000002
| HILMAN
|
500 |
| A000000003
| ANDIK
|
1500 |
| A000000004
| ANDIKA
|
500 |
+---------------+--------------+-------------+
3 rows in set (0.00 sec)
mysql> select a.nomor_anggota, a.nama_anggota, count(*) jml_buku_dipinjam
-> from anggota a inner join pinjam b on(a.nomor_anggota = b.nomor_anggota)
-> group by a.nomor_anggota;
+---------------+--------------+-------------------+
| nomor_anggota | nama_anggota | jml_buku_dipinjam |
+---------------+--------------+-------------------+
| A000000002
| HILMAN
|
1 |
| A000000003
| ANDIK
|
1 |
| A000000004
| ANDIKA
|
1 |
+---------------+--------------+-------------------+
3 rows in set (0.00 sec)
mysql> select * from pinjam;
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
| ID_PINJAM | NOMOR_SERI | NOMOR_ANGGOTA | NIP_PEG
| TGL_PINJAM | TGL_HARUS_K
EMBALI | TGL_KEMBALI | DENDA | STATUS |
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
|
1 | PERPUS0002 | A000000002
| P000000001 | 2011-12-23 | 2011-12-30
| NULL
| 500 |
1 |
|
2 | PERPUS0001 | A000000003
| P000000002 | 2011-12-23 | 2011-12-30
| NULL
| 1500 |
1 |
|
3 | PERPUS0003 | A000000004
| P000000001 | 2011-12-28 | 2012-01-04
| NULL
| 500 |
1 |
+-----------+------------+---------------+------------+------------+------------------+-------------+-------+--------+
3 rows in set (0.00 sec)
mysql> select a.nip_peg, a.nama_peg, count(*) jml_buku_dipinjamkan
-> from pegawai a inner join pinjam b on(a.nip_peg = b.nip_peg)
-> group by a.nip_peg;
+------------+----------+----------------------+
| nip_peg
| nama_peg | jml_buku_dipinjamkan |
+------------+----------+----------------------+
| P000000001 | LUKMAN |
2 |
| P000000002 | KAKA
|
1 |
+------------+----------+----------------------+
2 rows in set (0.00 sec)
mysql> select a.kode_buku, a.judul_buku, count(*) jml_pernah_dipinjam
-> from buku a inner join koleksi on(a.kode_buku)
-> inner join pinjam c on(b.nomor_seri = c.nomor_seri);
ERROR 1054 (42S22): Unknown column 'b.nomor_seri' in 'on clause'
mysql> select a.kode_buku, a.judul_buku, count(*) jml_pernah_dipinjam
-> from buku a inner join koleksi b on(a.kode_buku = b.kode_buku)
-> inner join pinjam c on(b.nomor_seri = c.nomor_seri);
ERROR 1140 (42000): Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GR
OUP columns is illegal if there is no GROUP BY clause
mysql> select a.kode_buku, a.judul_buku, count(*) jml_pernah_dipinjam

-> from buku a inner join koleksi b on(a.kode_buku = b.kode_buku)


-> inner join pinjam c on(b.nomor_seri = c.nomor_seri)
-> group by a.kode_buku;
+-----------+------------+---------------------+
| kode_buku | judul_buku | jml_pernah_dipinjam |
+-----------+------------+---------------------+
| B0001
| P.WEB
|
1 |
| B0002
| P.B.O
|
1 |
| B0003
| AGAMA
|
1 |
+-----------+------------+---------------------+
3 rows in set (0.00 sec)
mysql>

You might also like