TUGAS 2 SMBD
Posted: by Ajiex Estrada in
0
Modul 3 & 4 Sebelum nya klik DISINI
MODUL
LIMA
Soal latihan:
-
Table
employee_join
SELECT * FROM employee_join;
-
Table
job
SELECT * FROM job;
1.
Buatlah
function untuk menampilkan gabungan first_name dan last_name dengan bentuk
“last_name, first_name”.
DELIMITER
//
CREATE
FUNCTION revName( in_fist_name VARCHAR(15), in_last_name VARCHAR(15)) RETURNS
VARCHAR(35)
DETERMINISTIC
READS
SQL DATA
BEGIN
RETURN
CONCAT(in_fist_name,', ',in_last_name);
END//
DELIMITER
;
SELECT
revName(first_name, last_name) FROM employee_join;
2.
Buatlah procedure untuk
menampilkan job_description dari masukan sebuah id employee.
DELIMITER //
CREATE PROCEDURE empJob(IN id_emp VARCHAR(11))
BEGIN
SELECT employee_join.first_name, employee_join.last_name, job.title FROM employee_join
JOIN job ON employee_join.id = job.id WHERE employee_join.id LIKE id_emp;
END //
DELIMITER ;
CALL empJob(2);
Modul 6 Selanjutnya Klik DISINI