MySQL Views

  • Frank M. Kromann


Even relatively simplistic data-driven applications rely on queries involving several tables. For instance, suppose you were charged with creating a human resources application and wanted to create an interface that displays each employee’s name, e-mail address, total number of absences, and bonuses. The query might look like this:

SELECT emp.employee_id, emp.firstname, emp.lastname,,
       COUNT(att.absence) AS absences, COUNT(att.vacation) AS vacation,
       SUM(comp.bonus) AS bonus
FROM employees emp, attendance att, compensation comp
WHERE emp.employee_id = att.employee_id
AND emp.employee_id = comp.employee_id
GROUP BY emp.employee_id ASC
ORDER BY emp.lastname;

Copyright information

© Frank M. Kromann 2018

Authors and Affiliations

  • Frank M. Kromann
    • 1
  1. 1.Aliso ViejoUSA

Personalised recommendations