A: SQL statements for Tables: Patient, Doctor and Appointment II


a. Insert a new tuple in the relation patient.


INSERT INTO Patient
VALUES      ('P008',
             'Ramesh',
             'Dhangadhi',
             'Male',
             'Fever'); 


b. List all the patients who were checked by doctors Pankaj and Rubi.


SELECT p.PID,
       p.Pname
FROM   Patient p
       JOIN Appointment a
         ON p.PID = a.PID
       JOIN Doctor d
         ON d.DID = a.DID
WHERE  d.Dname = 'Pankaj'
        OR d.Dname = 'Rubi'; 


c. List name and id of doctors whose salary is less than Rs. 120,000.


SELECT Dname,
       DID
FROM   Doctor
WHERE  salary < 120000; 


d. Find name of patients whose name begins with 'Ru'.


SELECT Pname
FROM   Patient
WHERE  Pname LIKE 'Ru%'; 


e. Increase salary of all doctors by 10% who works in Forensic department.


UPDATE Doctor
SET    salary = salary * 1.10
WHERE  department = 'Forensic';