Advertisement
medvedya

Untitled

Jan 30th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.59 KB | None | 0 0
  1. CREATE
  2.     ALGORITHM = TEMPTABLE
  3. VIEW bd_hospital.view_all_patients_and_doctors AS
  4.     SELECT
  5.         pt.name AS pt_name, dc.name AS doc_name
  6.     FROM
  7.         bd_hospital.patient
  8.             JOIN
  9.         bd_hospital.doctor ON (bd_hospital.doctor.id = patient.id_doctor
  10.             OR patient.id_doctor = NULL)
  11.             JOIN
  12.         bd_hospital.person AS pt ON (pt.id = bd_hospital.patient.id_person
  13.             OR bd_hospital.patient.id_person = NULL)
  14.             JOIN
  15.         bd_hospital.person AS dc ON (bd_hospital.doctor.id_person = dc.id)
  16.     GROUP BY bd_hospital.patient.id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement