I have another question! My CRUD webapp is almost there, I do have a problem writing queries for my database! Database has 3 tables: Department, Location, Personnel.
Relationship is retrieved by using LEFT JOIN:
SELECT p.lastName,
p.firstName,
p.jobTitle,
p.email,
d.name as department,
l.name as location
FROM personnel p
LEFT JOIN department d ON (d.id = p.departmentID)
LEFT JOIN location l ON (l.id = d.locationID)
ORDER BY p.lastName, p.firstName, d.name, l.name
I need to write a delete query which will check for dependencies in database and warn user that if he is trying to delete entry that has dependencies.
I have this:
$query = 'DELETE FROM location WHERE id = ' . $_REQUEST['delete'];
which deletes entry but doesn't check for anything. I have been looking for solution for the past few hours and found nothing! How to write such a query! Can anyone help? Thanks Chi Chi