Subquery adalah Query didalam query. Artinya seleksi data berdasarkan hasil seleksi data yang telah ada. Sintax SQL nya sama syntax SQL pada umumnya, tetapi kondisi setelah where diikuti dengan query baru atau subquery. Syntaxnya :
SELECT nama_field-1,…..,nama_field-n
FROM nama_tabel
WHERE kriteria (SELECT nama_field-1, ……., nama_field-n
FROM nama_tabel
WHERE kriteria)
Contoh pemakaian QUERY
SELECT Last_name, salary, department_id, manager_id
FROM employees
WHERE salary =
(SELECT salary
FROM employees
WHERE department_id=40) ;
SELECT Last_name, salary, department_id, Manager_idFROM employeesWHERE salary =(SELECT salaryFROM employeesWHERE department_id=40)AND manager_id =(SELECT manager_idFROM employeesWHERE department_id=40) ;
SELECT Last_name, salary, department_id, Manager_idFROM employeesWHERE salary =(SELECT salaryFROM employeesWHERE department_id=40)OR manager_id =(SELECT manager_idFROM employeesWHERE department_id=40) ;
SELECT last_name, Department_id, salaryFROM employeesWHERE salary = ( SELECT MIN(salary)FROM employees) ;
Belum ada tanggapan untuk "Penggunaan SUBQUERIES Di (ORACLE)"
Post a Comment