SQL Server Performance

Delete from a table when not in 2 other tables

Discussion in 'General DBA Questions' started by melon.melon, Jun 18, 2009.

  1. melon.melon New Member

    hihi,
    Have problem deleting from a table when "no" is not found in 2 other tables.
    Delete table cant use alias like tbOne a
    Delete from tbCost1 where Not EXISTS (select * from tbCost2 a Inner Join tbCost3 b where a.no='222' and b.no='222') and no='222'
    neither is this working:
    Delete from t1 a left join t2 b on t2.no=t1.no
    left join t3 c on t3.no=t1.no where a.no='222'
    and b.no is null and c.no is null
  2. FrankKalis Moderator

    Welcome to the forum!
    I think you're missing the table alias right after DELETE
    Delete A from t1 a left join t2 b on t2.no=t1.no
    left join t3 c on t3.no=t1.no where a.no='222'
    and b.no is null and c.no is null
  3. Sandy New Member

    Melon,
    Frank is given your answer.
    Thank you,
    Sandy.
  4. melon.melon New Member

    Thank you and it works =)

Share This Page