Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.