Even relatively simplistic data-driven applications rely on queries involving several tables. For instance, suppose you want 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;

Queries of this nature are enough to send shudders down one's spine because of their size, particularly ...

Get Beginning PHP and MySQL: From Novice to Professional, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.