Delete from Sets

  • Hello there,

    I have two tables A and B. I Want to remove the rows in B that doesnt exist in A. Hence I have tried the following but it seems like there's some issues with the syntax. I looked all over and didnt seem to figure it out yet. Would u guys have any idea?

    Delete from B except select * from A

    Cheers

    Clement.store

  • Syntax will look like ,

    delete b from b where not exists(select 'x' from a where a.id=b.id)

  • Thanks. Can this be done using intersect/except...? Guess this can be a little faster using sets...?

  • The proposed solution does use sets - at least in the background.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • thanks all of u guys. Trying it out.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply