Options to Delete with Two Tables



--option 1
delete from jobs 
where exists  (select 1 from calibrations c where id =c.JobId)
--option 2
delete from jobs 
from calibrations c inner join jobs j on j.id =c.JobId

--option 3

delete from jobs 
where id in  (select Jobid from calibrations )

--This is not a good option if you use the id column from your delete table, all rows will be deleted
delete from jobs 
where id in  (select Id from calibrations )

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s