Jump to content

Not sure what to title this...


Kryptix

Recommended Posts

Say I have 3 tables...

 

employees

employees_addresses

employees_jobs_completed

 

If a linking ID between employees and employees_addresses doesn't exist I want to delete all records from every table even though employees_jobs_completed may have either 0 entries or a thousand entries...

 

Would this work?

 

DELETE employees.*, employees_addresses.*, employees_jobs_completed FROM employees JOIN employees_addresses ON (employees.id = employees_addresses.e_id) LEFT JOIN employees_jobs_completed ON (employees.id = employees_jobs_completed.e_id) WHERE employees.id IS NULL OR employees_addresses.id IS NULL;

 

Note the LEFT JOIN on employees_jobs_completed in case it has no entries or 1-1,000 entries. Is this the correct usage?

 

If not, how would I go about doing it within a query?

Link to comment
https://forums.phpfreaks.com/topic/245161-not-sure-what-to-title-this/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.