You are on page 1of 36

Microsoft Windows [Version 10.0.22000.

434]

(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd..

C:\Windows>cd..

C:\>cd xampp\mysql\bin

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

Enter password:

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

Your MariaDB connection id is 8

Server version: 10.4.24-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)]> show databases;

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

| Database |

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

| akademik |

| baru |

| data_perpulangan |

| information_schema |

| kuliah |

| mahasiswa |
| materi |

| minimarket |

| mysql |

| penjualan |

| performance_schema |

| phpmyadmin |

| si_rumah_sakit |

| t9 |

| test |

| uts |

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

16 rows in set (0.048 sec)

MariaDB [(none)]> use baru;

Database changed

MariaDB [baru]> DELIMITER //

MariaDB [baru]> CRETAE PROCEDURE TampilBaru()

-> BEGIN

-> SELECT nip, nama, kota, tgl_lahir, jk from infopribadi where kota = 'solo' and jk = 'L' or kota = 'yogya'
and jk = 'L';

-> END//

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 'CRETAE PROCEDURE TampilBaru()

BEGIN

SELECT nip, nama, kota, tgl_lahir, jk fro...' at line 1

MariaDB [baru]> CREATE PROCEDURE TampilBaru()

-> BEGIN

-> SELECT nip, nama, kota, tgl_lahir, jk from infopribadi where kota = 'solo' and jk = 'L' or kota = 'yogya'
and jk = 'L';

-> END//
Query OK, 0 rows affected (0.074 sec)

MariaDB [baru]> CALL TampilBaru();

-> DELIMITER//

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

| nip | nama | kota | tgl_lahir | jk |

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

| 12345 | dian permana | yogya | 1987-09-03 | L |

| 12349 | dhani akbar | yogya | 1988-02-09 | L |

| 12350 | aan setiawan | yogya | 1982-07-22 | L |

| 12357 | danang saputro | solo | 1982-07-01 | L |

| 12360 | prabu galih | yogya | 1985-02-24 | L |

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

5 rows in set (0.094 sec)

Query OK, 0 rows affected (0.748 sec)

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 'DELIMITER' at line 1

MariaDB [baru]> DELIMITER $$

MariaDB [baru]> CREATE PROCEDURE TampilCuaca(

-> IN nik VARCHAR(10),

-> OUT cuaca VARCHAR(20))

-> BEGIN

-> DECLARE KotaOrang VARCHAR(20);

-> SELECT kota

-> INTO KotaOrang

-> FROM infopribadi

-> WHERE nik = nip;


-> CASE KotaOrang

-> WHEN 'yogya' THEN

-> SET cuaca = 'Mendung';

-> WHEN 'klaten' THEN

-> SET cuaca = 'Hujan';

-> WHEN 'solo' THEN

-> SET cuaca = 'Berawan';

-> ELSE

-> SET cucaca = 'Cerah';

-> END CASE;

-> END$$

ERROR 1193 (HY000): Unknown system variable 'cucaca'

MariaDB [baru]> CREATE PROCEDURE TampilCuaca(

-> IN nik VARCHAR(10),

-> -> OUT cuaca VARCHAR(20))

-> -> BEGIN

-> -> DECLARE KotaOrang VARCHAR(20);

-> -> SELECT kota

-> -> INTO KotaOrang

-> -> FROM infopribadi

-> -> WHERE nik = nip;

-> -> CASE KotaOrang

-> -> WHEN 'yogya' THEN

-> -> SET cuaca = 'Mendung';

-> -> WHEN 'klaten' THEN

-> -> SET cuaca = 'Hujan';

-> -> WHEN 'solo' THEN

-> -> SET cuaca = 'Berawan';

-> -> SET cuaca = 'Hujan^Z^Z^Z^Z


'> END$$

'>

'> ByeCtrl-C -- exit!

C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd..

C:\xampp>cd xampp\mysql\bin

The system cannot find the path specified.

C:\xampp>cd..

C:\>cd xampp\mysql\bin

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

Enter password:

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

Your MariaDB connection id is 9

Server version: 10.4.24-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 baru

Database changed

MariaDB [baru]> DELIMITER $$


MariaDB [baru]> CREATE PROCEDURE TampilCuaca(

-> IN nik VARCHAR(10),

-> OUT cuaca VARCHAR(20))

-> BEGIN

-> DECLARE KotaOrang VARCHAR(20);

-> SELECT kota

-> INTO KotaOrang

-> FROM infopribadi

-> WHERE nik = nip;

-> CASE KotaOrang

-> WHEN 'yogya' THEN

-> SET cuaca = 'Mendung';

-> WHEN 'klaten' THEN

-> SET cuaca = 'Hujan';

-> WHEN 'solo' THEN

-> SET cuaca = 'Berawan';

-> ELSE

-> SET cuaca = 'Cerah';

-> END CASE;

-> END$$

Query OK, 0 rows affected (0.055 sec)

MariaDB [baru]> CALL TampilCuaca(12345,@cuaca);

-> SELECT @cuaca;

-> $$

Query OK, 1 row affected (0.013 sec)

+---------+

| @cuaca |
+---------+

| Mendung |

+---------+

1 row in set (0.014 sec)

MariaDB [baru]> select * from transaksi_detail;

-> ;

-> END$$

ERROR 1146 (42S02): Table 'baru.transaksi_detail' doesn't exist

MariaDB [baru]> show databases;

-> ByeCtrl-C -- exit!

C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd..

C:\xampp>cd..

C:\>cd xamppp\mysql\bin

The system cannot find the path specified.

C:\>cd..

C:\>cd xampp\mysql\bin

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

'mysql-u' is not recognized as an internal or external command,

operable program or batch file.


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

Enter password:

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

Your MariaDB connection id is 10

Server version: 10.4.24-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)]> show databases;

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

| Database |

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

| akademik |

| baru |

| data_perpulangan |

| information_schema |

| kuliah |

| mahasiswa |

| materi |

| minimarket |

| mysql |

| penjualan |

| performance_schema |

| phpmyadmin |

| si_rumah_sakit |

| t9 |
| test |

| uts |

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

16 rows in set (0.003 sec)

MariaDB [(none)]>
Microsoft Windows [Version 10.0.22000.434]

(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>cd..

C:\Windows>cd..

C:\>cd xampp\mysql\bin

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

'mysql-u' is not recognized as an internal or external command,

operable program or batch file.

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

Enter password:

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

Your MariaDB connection id is 8

Server version: 10.4.24-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)]> create databaase store;

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 'databaase store' at line 1

MariaDB [(none)]> create database store;

Query OK, 1 row affected (0.016 sec)


MariaDB [(none)]> use store

Database changed

MariaDB [store]> create table (

-> ID_Transaksi_Detail

-> ID_Transaksi

-> ID_Barang

-> Jumlah_Barang

-> Harga_Satuan );

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 '(

ID_Transaksi_Detail

ID_Transaksi

ID_Barang

Jumlah_Barang

Harga_Satuan )' at line 1

MariaDB [store]> create table (

-> ID_Transaksi_Detail int(10),

-> ID_Transaksi int(10),

-> ID_Barang int(5),

-> Jumlah_Barang int(5),

-> Harga_Satuan int(10);

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 '(

ID_Transaksi_Detail int(10),

ID_Transaksi int(10),

ID_Barang int(5),

Jumlah...' at line 1

MariaDB [store]> create table store (

-> ID_Transaksi_Detail int(10),


-> ID_Transaksi int(10),

-> ID_Barang int(5),

-> Jumlah_Barang int(5),

-> Harga_Satuan int(10));

Query OK, 0 rows affected (0.080 sec)

MariaDB [store]> insert into store values

-> ('001', '101', '201', '1', '50000');

Query OK, 1 row affected (0.064 sec)

MariaDB [store]> select*from store;

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

| ID_Transaksi_Detail | ID_Transaksi | ID_Barang | Jumlah_Barang | Harga_Satuan |

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

| 1| 101 | 201 | 1| 50000 |

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

1 row in set (0.010 sec)

MariaDB [store]> insert into store values

-> ('002', '102', '202', '1', '75000'),

-> ('003', '103', '203', '1', '45000'),

-> ('004', '104', '204', '1', '80000'),

-> ('005', '105', '205', '1', '10000'),

-> ('006', '106', '206', '1', '15000'),

-> ('007', '107', '207', '1', '35000');

Query OK, 6 rows affected (0.040 sec)

Records: 6 Duplicates: 0 Warnings: 0

MariaDB [store]> select*from store;


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

| ID_Transaksi_Detail | ID_Transaksi | ID_Barang | Jumlah_Barang | Harga_Satuan |

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

| 1| 101 | 201 | 1| 50000 |

| 2| 102 | 202 | 1| 75000 |

| 3| 103 | 203 | 1| 45000 |

| 4| 104 | 204 | 1| 80000 |

| 5| 105 | 205 | 1| 10000 |

| 6| 106 | 206 | 1| 15000 |

| 7| 107 | 207 | 1| 35000 |

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

7 rows in set (0.007 sec)

MariaDB [store]> CREATE VIEW jumlahtransaksi AS

-> SELECT

-> ID_Transaksi,

-> SUM(Jumlah_Barang * Harga_Satuan) total

-> FROM

-> store

-> GROUP by ID_Transaksi

-> ORDER by total DESC;

Query OK, 0 rows affected (0.022 sec)

MariaDB [store]> select*from jumlahtransaksi;

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

| ID_Transaksi | total |

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

| 104 | 80000 |

| 102 | 75000 |
| 101 | 50000 |

| 103 | 45000 |

| 107 | 35000 |

| 106 | 15000 |

| 105 | 10000 |

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

7 rows in set (0.007 sec)

MariaDB [store]> CREATE DATABASE study;

Query OK, 1 row affected (0.003 sec)

MariaDB [store]> use study;

Database changed

MariaDB [study]> create table study (

-> ID_Buku int(5),

-> Nama_Buku varchar(20),

-> Jumlah int(5));

Query OK, 0 rows affected (0.047 sec)

MariaDB [study]> insert into study values

-> ('020', 'Basis Data', '5'),

-> ('021', 'Aljabar Linear', '3'),

-> ('022', 'Dasar-Dasar Pemrograman', '4'),

-> ('023', 'Pemrograman Web', '10'),

-> );

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 ')' at line 6

MariaDB [study]> insert into study values

-> ('020', 'Basis Data', '5'),


-> ('021', 'Aljabar Linear', '3'),

-> ('022', 'Dasar-Dasar Pemrograman', '4'),

-> ('023', 'Pemrograman Web', '10'));

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 ')' at line 5

MariaDB [study]> insert into study values

-> ('020', 'Basis Data', '5'),

-> ('021', 'Aljabar Linear', '3'),

-> ('022', 'Dasar-Dasar Pemrograman', '4'),

-> ('023', 'Pemrograman Web', '10');

Query OK, 4 rows affected, 1 warning (0.015 sec)

Records: 4 Duplicates: 0 Warnings: 1

MariaDB [study]> DELIMITER//

-> ;

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 'DELIMITER//' at line 1

MariaDB [study]> DELIMITER //

MariaDB [study]> CREATE TRIGGER jumlahbuku

-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE books

-> SET jumlah=jumlah-NEW.jumlah_pinjam

-> WHRE ID_buku=NEW.ID_Buku;

-> END //

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 'WHRE ID_buku=NEW.ID_Buku;

END' at line 7

MariaDB [study]> CREATE TRIGGER jumlahbuku


-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE books

-> SET jumlah=jumlah-NEW.jumlah_pinjam

-> WHERE ID_Buku=NEW.ID_Buku;

-> END //

ERROR 1146 (42S02): Table 'study.peminjaman' doesn't exist

MariaDB [study]> select*from study;

-> select;

-> ;

-> );

-> //

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 20 | Basis Data | 5|

| 21 | Aljabar Linear | 3|

| 22 | Dasar-Dasar Pemrogra | 4|

| 23 | Pemrograman Web | 10 |

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

4 rows in set (0.001 sec)

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 ';

)' at line 1

MariaDB [study]> CREATE TRIGGER jumlahbuku

-> AFTER INSERT ON peminjaman


-> FOR EACH ROW

-> BEGIN

-> UPDATE books

-> SET jumlah=jumlah-NEW.jumlah_pinjam

-> WHERE ID_Buku=NEW.ID_Buku;

-> END //

ERROR 1146 (42S02): Table 'study.peminjaman' doesn't exist

MariaDB [study]> create table peminjaman(

-> ID_Peminjaman int,

-> Nama_Peminjam varchar(50),

-> ID_Buku int,

-> Jumlah_Pinjam tinyint,

-> primary key(ID_Peminjaman);

-> );

-> ));

-> ;

-> 00;

-> //

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 ';

);

));

00' at line 6

MariaDB [study]> create table peminjaman(

-> ID_Peminjaman int,

-> Nama_Peminjam varchar(50),

-> Ctrl-C -- exit!

Bye
C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd..

C:\xampp>cd..

C:\>cd xampp\mysql\bin

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

Enter password:

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

Your MariaDB connection id is 9

Server version: 10.4.24-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 study;

Database changed

MariaDB [study]> select*from study;

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 20 | Basis Data | 5|

| 21 | Aljabar Linear | 3|

| 22 | Dasar-Dasar Pemrogra | 4|

| 23 | Pemrograman Web | 10 |
+---------+----------------------+--------+

4 rows in set (0.024 sec)

MariaDB [study]> alter table study add primarykey(ID_Buku);

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 '(ID_Buku)' at line 1

MariaDB [study]> alter table study add primary key(ID_Buku);

Query OK, 0 rows affected (0.181 sec)

Records: 0 Duplicates: 0 Warnings: 0

MariaDB [study]> desc study;

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

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

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

| ID_Buku | int(5) | NO | PRI | NULL | |

| Nama_Buku | varchar(20) | YES | | NULL | |

| Jumlah | int(5) | YES | | NULL | |

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

3 rows in set (0.045 sec)

MariaDB [study]> create table peminjaman (

-> ID_Peminjaman int,

-> Nama_Peminjam varchar(50),

-> ID_Buku int,

-> Jumlah_Pinjam tinyint,

-> primary key(ID_Peminjaman)

-> );

Query OK, 0 rows affected (0.113 sec)


MariaDB [study]> DELIMITER //

MariaDB [study]> CREATE TRIGGER JumlahBuku

-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE buku

-> SET jumlah=jumlah-NEW.jumlah_pinjam

-> WHERE ID_Buku=NEW.ID_Buku;

-> END //

Query OK, 0 rows affected (0.043 sec)

MariaDB [study]> DELIMITER ;

MariaDB [study]> SELECT*FROM buku;

ERROR 1146 (42S02): Table 'study.buku' doesn't exist

MariaDB [study]> select*from study;

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 20 | Basis Data | 5|

| 21 | Aljabar Linear | 3|

| 22 | Dasar-Dasar Pemrogra | 4|

| 23 | Pemrograman Web | 10 |

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

4 rows in set (0.004 sec)

MariaDB [study]> INSERT INTO PEMINJAMAN VALUES(1, "Fifid", 23, 5);

ERROR 1146 (42S02): Table 'study.buku' doesn't exist

MariaDB [study]> insert into peminjaman values (1, "Fifid", 23, 5);

ERROR 1146 (42S02): Table 'study.buku' doesn't exist


MariaDB [study]> ByeCtrl-C -- exit!

C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd.

C:\xampp\mysql>

C:\xampp\mysql>cd..

C:\xampp>cd..

C:\>cd xampp\mysql\bin

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

Enter password:

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

Your MariaDB connection id is 10

Server version: 10.4.24-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)]> show databases;

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

| Database |

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

| akademik |
| baru |

| data_perpulangan |

| information_schema |

| kuliah |

| mahasiswa |

| materi |

| minimarket |

| mysql |

| penjualan |

| performance_schema |

| phpmyadmin |

| si_rumah_sakit |

| store |

| study |

| t9 |

| test |

| uts |

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

18 rows in set (0.100 sec)

MariaDB [(none)]> drop database study;

Query OK, 2 rows affected (0.145 sec)

MariaDB [(none)]> create table buku(

-> ID_Buku int(5),Nama_Buku varchar(20),;

ERROR 1046 (3D000): No database selected

MariaDB [(none)]> create database perpustakaan;

Query OK, 1 row affected (0.027 sec)


MariaDB [(none)]> create table buku(

-> Jumlah int(5));

ERROR 1046 (3D000): No database selected

MariaDB [(none)]> create table buku(

-> ID_Buku int(5),

-> Nama_Buku varchar(20),

-> Jumlah;

ERROR 1046 (3D000): No database selected

MariaDB [(none)]> use perpustakaan;

Database changed

MariaDB [perpustakaan]> create table buku(

-> ID_Buku int(5),

-> Nama_Buku varchar(20),

-> Jumlah int(5),

-> primary key(ID_Buku));

Query OK, 0 rows affected (0.070 sec)

MariaDB [perpustakaan]> create table peminjaman(

-> ID_Peminjaman int,

-> Nama_Peminjam varchar(50),ID_Buku int,

-> );

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 ')' at line 4

MariaDB [perpustakaan]> create table peminjaman(

-> ID_Peminjaman int,

-> Nama_Peminjam varchar(50),

-> ID_Buku int,

-> Jumlah_Pinjam tinyint,

-> primary key(ID_Peminjaman));


Query OK, 0 rows affected (0.096 sec)

MariaDB [perpustakaan]> insert into buku values

-> ('020', 'Basis Data', '20),

'> ('021', 'Aljabar Linear', '10'),

'> ('022', 'Dasar-Dasar Pemrograman', '15');

'> );

'> ;;

'> ));

'> );

'> );

'> ;

'> 000;//

'> //

'> END//

'> :'

-> Ctrl-C -- exit!

Bye

C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd..

C:\xampp>cd..

C:\>cd xampp\mysql\bin

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

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

Your MariaDB connection id is 11

Server version: 10.4.24-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 perpustakaan;

Database changed

MariaDB [perpustakaan]> insert into buku values

-> ('010', 'Basis Data', '20'),

-> ('011', 'Aljabar Linear', '15'),

-> ('012', 'Web Development', '25');

Query OK, 3 rows affected (0.025 sec)

Records: 3 Duplicates: 0 Warnings: 0

MariaDB [perpustakaan]> select*from buku;

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 10 | Basis Data | 20 |

| 11 | Aljabar Linear | 15 |

| 12 | Web Development | 25 |

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

3 rows in set (0.008 sec)

MariaDB [perpustakaan]> DELIMITER //

MariaDB [perpustakaan]> CREATE TRIGGER JumlahBuku


-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE buku

-> SET jumlah=jumlah-New.jumlah_pinjam

-> WHERE ID_Buku=New.ID_Buku

-> END //

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 'END' at line 8

MariaDB [perpustakaan]> CREATE TRIGGER JumlahBuku

-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE buku

-> SET jumlah=jumlah-New.jumlah_pinjam

-> WHERE ID_Buku=New.ID_Buku

-> END//

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 'END' at line 8

MariaDB [perpustakaan]> DELIMITER //

MariaDB [perpustakaan]> CREATE TRIGGER jumlahBuku

-> AFTER INSERT ON peminjaman

-> FOR EACH ROW

-> BEGIN

-> UPDATE buku

-> SET jumlah=jumlah-NEW.jumlah_pinjam

-> WHERE ID_Buku=NEW.ID_Buku;

-> END//

Query OK, 0 rows affected (0.084 sec)


MariaDB [perpustakaan]> DELIMITER ;

MariaDB [perpustakaan]> select * from buku

-> ;

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 10 | Basis Data | 20 |

| 11 | Aljabar Linear | 15 |

| 12 | Web Development | 25 |

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

3 rows in set (0.015 sec)

MariaDB [perpustakaan]> INSERT INTO peminjaman values (1, "Fifid", 12, 4);

Query OK, 1 row affected (0.062 sec)

MariaDB [perpustakaan]> select*from peminjaman;

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

| ID_Peminjaman | Nama_Peminjam | ID_Buku | Jumlah_Pinjam |

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

| 1 | Fifid | 12 | 4|

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

1 row in set (0.000 sec)

MariaDB [perpustakaan]> select*from buku;

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

| ID_Buku | Nama_Buku | Jumlah |

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

| 10 | Basis Data | 20 |
| 11 | Aljabar Linear | 15 |

| 12 | Web Development | 21 |

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

3 rows in set (0.000 sec)

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

Bye

C:\xampp\mysql\bin>cd..

C:\xampp\mysql>cd..

C:\xampp>cd..

C:\>cd xampp\mysql\bin

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

Enter password:

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

Your MariaDB connection id is 12

Server version: 10.4.24-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)]> create database working;

Query OK, 1 row affected (0.022 sec)


MariaDB [(none)]> create table pekerjaan;

ERROR 1046 (3D000): No database selected

MariaDB [(none)]> use working;

Database changed

MariaDB [working]> create table pekerjaan

-> NIP int(10),

-> KODE_BAG int(10),

-> GAJI int(15);

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 'int(10),

KODE_BAG int(10),

GAJI int(15)' at line 2

MariaDB [working]> create table pekerjaan (

-> NIP int(10),

-> KODE_BAG int(10),

-> GAJI int(15));

Query OK, 0 rows affected (0.078 sec)

MariaDB [working]> select*from pekerjaan;

Empty set (0.016 sec)

MariaDB [working]> insert into pekerjaan values

-> ('4567', '2', '350000'),

-> ('4568', '3', '430000'),

-> ('4569', '2', '250000'),

-> ('4570', '4', '300000');

Query OK, 4 rows affected (0.035 sec)

Records: 4 Duplicates: 0 Warnings: 0


MariaDB [working]> select*from pekerjaan;

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

| NIP | KODE_BAG | GAJI |

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

| 4567 | 2 | 350000 |

| 4568 | 3 | 430000 |

| 4569 | 2 | 250000 |

| 4570 | 4 | 300000 |

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

4 rows in set (0.007 sec)

MariaDB [working]> select*from infopribadi;

ERROR 1146 (42S02): Table 'working.infopribadi' doesn't exist

MariaDB [working]> use baru;

Database changed

MariaDB [baru]> select*from infopribadi;

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

| nip | nama | kota | tgl_lahir | jk |

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

| 12345 | dian permana | yogya | 1987-09-03 | L |

| 12346 | tamara febrianti | klaten | 1985-03-21 | W |

| 12347 | dara permatasari | sragen | 1984-04-27 | W |

| 12348 | dita nurfani | klaten | 1985-03-07 | W |

| 12349 | dhani akbar | yogya | 1988-02-09 | L |

| 12350 | aan setiawan | yogya | 1982-07-22 | L |

| 12351 | roul sitompul | bantul | 1983-07-22 | L |

| 12352 | rahmanda | yogya | 1983-03-29 | W |

| 12353 | niken | klaten | 1982-09-21 | W |

| 12354 | inneke safitri | bantul | 1985-04-22 | w |


| 12355 | nadia putri | solo | 1980-03-08 | W |

| 12356 | citra puri | yogya | 1981-06-22 | W |

| 12357 | danang saputro | solo | 1982-07-01 | L |

| 12358 | dadang wicaksono | klaten | 1979-09-27 | L |

| 12359 | citra putri | solo | 1978-09-01 | W |

| 12360 | prabu galih | yogya | 1985-02-24 | L |

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

16 rows in set (0.047 sec)

MariaDB [baru]> use working;

Database changed

MariaDB [working]> drop table pekerjaan;

Query OK, 0 rows affected (0.043 sec)

MariaDB [working]> create table pekerjaan;

ERROR 1113 (42000): A table must have at least 1 column

MariaDB [working]> create table pekerjaan (

-> NIP int(10),

-> KODE_BAG int(10),

-> GAJI int(15));

Query OK, 0 rows affected (0.059 sec)

MariaDB [working]> insert into pekerjaan values

-> ('12345', '2', '450000'),

-> ('12346', '4', '650000'),

-> ('12347', '3', '400000'),

-> ('12348', '1', '300000'),

-> ('12349', '5', '230000'),

-> ('12350', '2', '360000'),


-> ('12351', '2', '500000'),

-> ('12352', '4', ' 700000'),

-> ('12353', '3', ' 450000'),

-> ('12354', '4', ' 240000'),

-> ('12355', '1', ' 700000'),

-> ('12356', '2', ' 180000'),

-> ('12357', '5', ' 340000'),

-> ('12358', '1', ' 100000'),

-> ('12359', '5', ' 320000'),

-> ('12360', '1', ' 90000');

Query OK, 16 rows affected (0.056 sec)

Records: 16 Duplicates: 0 Warnings: 0

MariaDB [working]> select*from pekerjaan;

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

| NIP | KODE_BAG | GAJI |

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

| 12345 | 2 | 450000 |

| 12346 | 4 | 650000 |

| 12347 | 3 | 400000 |

| 12348 | 1 | 300000 |

| 12349 | 5 | 230000 |

| 12350 | 2 | 360000 |

| 12351 | 2 | 500000 |

| 12352 | 4 | 700000 |

| 12353 | 3 | 450000 |

| 12354 | 4 | 240000 |

| 12355 | 1 | 700000 |

| 12356 | 2 | 180000 |
| 12357 | 5 | 340000 |

| 12358 | 1 | 100000 |

| 12359 | 5 | 320000 |

| 12360 | 1 | 90000 |

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

16 rows in set (0.013 sec)

MariaDB [working]> DELIMITER //

MariaDB [working]> CREATE PROCEDURE GajiTiapKaryawan()

-> select a.nama, a.kota, b.KODE_BAG, b.GAJI from infopribadi a,

-> pekerjaan b where a.nip=b.NIP;

-> //

Query OK, 0 rows affected (0.036 sec)

MariaDB [working]> DELIMITER //

MariaDB [working]> CREATE PROCEDURE GajiTiapKaryawan()

-> select a.nama, a.kota, b.KODE_BAG, b.GAJI from infopribadi a,pekerjaan b where a.nip=b.NIP;

-> END//

ERROR 1304 (42000): PROCEDURE GajiTiapKaryawan already exists

MariaDB [working]> drop procedure GajiTiapKaryawan;

-> END//

Query OK, 0 rows affected (0.275 sec)

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 'END' at line 1

MariaDB [working]> CREATE PROCEDURE GajiTiapKaryawan()

-> select a.nama, a.kota, b.KODE_BAG, b.GAJI from infopribadi a,pekerjaan b where a.nip=b.NIP;

-> END//

Query OK, 0 rows affected (0.028 sec)


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 'END' at line 1

MariaDB [working]> CALL GajiTiapKaryawan()//

ERROR 1146 (42S02): Table 'working.infopribadi' doesn't exist

MariaDB [working]> use baru;

ERROR 1049 (42000): Unknown database 'baru;'

MariaDB [working]> use baru;

ERROR 1049 (42000): Unknown database 'baru;'

MariaDB [working]> show databases;

-> ;

-> ));

-> //

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

| Database |

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

| akademik |

| baru |

| data_perpulangan |

| information_schema |

| kuliah |

| mahasiswa |

| materi |

| minimarket |

| mysql |

| penjualan |

| performance_schema |

| perpustakaan |

| phpmyadmin |
| si_rumah_sakit |

| store |

| t9 |

| test |

| uts |

| working |

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

19 rows in set (0.011 sec)

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 ';

))' at line 1

MariaDB [working]> use baru

Database changed

MariaDB [baru]> CALL GajiTiapKaryawan()//

ERROR 1305 (42000): PROCEDURE baru.GajiTiapKaryawan does not exist

MariaDB [baru]> DELIMITER //

MariaDB [baru]> CREATE PROCEDURE GajiTiapKaryawan()

-> select a.nama, a.kota, b.KODE_BAG, b.GAJI from infopribadi a,pekerjaan b where a.nip=b.NIP;

-> END//

Query OK, 0 rows affected (0.013 sec)

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 'END' at line 1

MariaDB [baru]> CALL GajiTiapKaryawan()//

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

| nama | kota | KODE_BAG | GAJI |

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

| dian permana | yogya | 2 | 1200000 |


| tamara febrianti | klaten | 1 | 1000000 |

| dara permatasari | sragen | 3 | 1200000 |

| dita nurfani | klaten | 4 | 1200000 |

| dhani akbar | yogya | 1 | 1000000 |

| aan setiawan | yogya | 2 | 1000000 |

| roul sitompul | bantul | 2 | 1400000 |

| rahmanda | yogya | 1 | 1000000 |

| niken | klaten | 1 | 1000000 |

| inneke safitri | bantul | 1 | 900000 |

| nadia putri | solo | 3 | 2300000 |

| citra puri | yogya | 5 | 3100000 |

| danang saputro | solo | 3 | 1800000 |

| dadang wicaksono | klaten | 5 | 1378000 |

| citra putri | solo | 5 | 5670000 |

| prabu galih | yogya | 3 | 2389000 |

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

16 rows in set (0.060 sec)

Query OK, 0 rows affected (2.114 sec)

MariaDB [baru]>

You might also like