Delete script

I would like to delete values in one table that don't exist in another.

for example
delete from glf_chart_acct where accnbri does not exist in table glf_ldg_acc_trans
What would be the correct syntax for this?
Matthew34Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rushShahConnect With a Mentor Commented:
try this,
delete 
from glf_chart_acct a
LEFT JOIN glf_ldg_acc_trans t ON a.accnbri = t.accnbri
where t.accnbri is null

Open in new window

0
 
jimyXConnect With a Mentor Commented:
delete from glf_chart_acct where NOT EXISTS (select accnbri from table glf_ldg_acc_trans)
0
 
jimyXConnect With a Mentor Commented:
or,
delete from glf_chart_acct where NOT EXISTS (select glf_ldg_acc_trans.accnbri from table glf_ldg_acc_trans where glf_ldg_acc_trans.accnbri = glf_chart_acct.accnbri)
0
 
Matthew34Author Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.