DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Delete!!!

  1. #1
    Join Date
    Aug 2002
    Posts
    27

    Question Delete!!!

    Hi All,
    Let table A and table B have the same structure.
    and records in B are subset of records in A.
    Can I delete all the reords in A that are in B in one SQL statement?
    If not, is there a simple way?
    NOTE: no unique columns exist in A and B

    Best Regards
    Omran
    Mohammed Omran, PhD

  2. #2
    Join Date
    Aug 2000
    Location
    Shanghai
    Posts
    433
    delete from a where
    (a.pk1,a.pk2) in
    (select b.pk1,b.pk2 from b)
    1. www.dbasupport.com
    2. www.dbforums.com
    3. www.itpub.net
    4. www.csdn.net
    5. www.umlchina.com
    6. www.tek-tips.com
    7. www.cnforyou.com
    8. fm365.federal.com.cn
    9. www.programmersheaven.com
    10.http://msdn.microsoft.com/library/default.asp
    ligang1000@hotmail.com

  3. #3
    Join Date
    Mar 2002
    Posts
    200
    I wouldn't think the prefixing of the table names with the columns is necessary as the statements are locally self-contained.

  4. #4
    Join Date
    Aug 2002
    Posts
    27
    Thank you very much
    Mohammed Omran, PhD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width