You are on page 1of 7

Arranged By

Nur Rizal (4101418097)


Chapter I
In this section the command is using the table that we created last week,
and make another table with name enroll_mata_kuliah. Then use join
command to merge them and resolve these following problems:
1. Show data of student names, courses they take, and SKS.
2. Show data on the name of the student, the course they took, and
their grades.
3. Show student code data, course code they took, and their grades.
Chapter II
We start with launch XAMPP Control Panel v3.2.4. After that, choose
start on Apache and MySQL options. Then open Command Prompt and
start our querry here. Start with CD and our file directory of bin in mysql
folder. In here my file directory is C:\xampp\mysql\bin. After that mysql -u
root -p and we will get command to enter the password, just type Enter or
empty our password. The next querry is using my database that we made
before by USE databasepertemuan2_4101418097.
We use querry SELECT *from mhs_tb; to show all the data in our table
before.

Then, we create another table with the name enroll_mata_kuliah. Use this
query, CREATE TABLE enroll_mata_kuliah (Kode_Mata_Kuliah
varchar(20) not null primary key, Nama_Mata_Kuliah varchar(25),
Jumlah_SKS int(1), Semester int(1), NIM_Pengambil int(7), Nilai
varchar(1));
Next, input all data for new table.
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘MATDAS’, ’Matematika Dasar’, ’4’, ’1’, ’066001’, ’A’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘FISDAS’, ’Fisika Dasar’, ’2’, ’1’, ’066002’, ’A’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘KAL1’, ’Kalkulus 1’, ’1’, ’1’, ’066009’, ’B’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘ALEL’, ’Aljabar Linear’, ’2’, ’2’, ’066009’, ’AB’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘PROKOM’, ’Pemrograman Komputer’, ’3’, ’3’, ’066002’, ’C’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘DTBASE’, ’Database’, ’4’, ’4’, ’066091’, ’D’);
Then the result of our new table will be like this. SELECT from
enroll_mata_kuliah;

For first problem, we display Nama_Mata_Kuliah, Jumlah_SKS, and the


students that took it. SELECT Nama_Mata_Kuliah,Jumlah_SKS,
nama_mhs FROM enroll_mata_kuliah INNER JOIN mhs_tb ON
NIM_Pengambil=NIM;

For, the Second problem, we use the query SELECT


Nama_Mata_Kuliah,Nilai, nama_mhs FROM enroll_mata_kuliah INNER
JOIN mhs_tb ON NIM_Pengambil=NIM;

For, the third problem, we use the query SELECT


Kode_Mata_Kuliah,Nilai, NIM FROM enroll_mata_kuliah INNER JOIN
mhs_tb ON NIM_Pengambil=NIM;
Chapter III
CD C:\xampp\mysql\bin
mysql -u root -p

USE databasepertemuan2_4101418097;
SHOW TABLES;
SELECT *from mhs_tb;
CREATE TABLE enroll_mata_kuliah (Kode_Mata_Kuliah varchar(20)
not null primary key, Nama_Mata_Kuliah varchar(25), Jumlah_SKS
int(1), Semester int(1), NIM_Pengambil int(7), Nilai varchar(1));
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘MATDAS’, ’Matematika Dasar’, ’4’, ’1’, ’066001’, ’A’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘FISDAS’, ’Fisika Dasar’, ’2’, ’1’, ’066002’, ’A’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘KAL1’, ’Kalkulus 1’, ’1’, ’1’, ’066009’, ’B’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘ALEL’, ’Aljabar Linear’, ’2’, ’2’, ’066009’, ’AB’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘PROKOM’, ’Pemrograman Komputer’, ’3’, ’3’, ’066002’, ’C’);
INSERT INTO enroll_mata_kuliah (Kode_Mata_Kuliah,
Nama_Mata_Kuliah, Jumlah_SKS, Semester, NIM_Pengambil, Nilai)
values (‘DTBASE’, ’Database’, ’4’, ’4’, ’066091’, ’D’);
SELECT *from enroll_mata_kuliah;
SELECT Nama_Mata_Kuliah,Jumlah_SKS, nama_mhs FROM
enroll_mata_kuliah INNER JOIN mhs_tb ON NIM_Pengambil=NIM;
SELECT Nama_Mata_Kuliah,Nilai, nama_mhs FROM
enroll_mata_kuliah INNER JOIN mhs_tb ON NIM_Pengambil=NIM;
SELECT Kode_Mata_Kuliah,Nilai, NIM FROM enroll_mata_kuliah
INNER JOIN mhs_tb ON NIM_Pengambil=NIM;
Chapter IV
This is the result of this section.
Chapter V
We use inner join query and we can merge and combine some data from
two tables or more.

You might also like