How do I delete rows from one table based off another?

  • How do I delete the rows from one table where they are not in the other table or where they have a certain status?

    My tables are as follows:

    Table 1:

    DBID

    DBname

    Size

    Table 2: (this table holds rows from multiple dates)

    StatsID

    DBName

    Status

    Start Time

    End Time

    I want to delete from Table 1 where the DBnames are in Table 2 and have status of 'Success' for only the current date.

  • delete from Table1

    where ColumnName in (select ColumnName from Table2 where ...)

    That's usually the easiest way to do that kind of thing.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Thank You!!!

Viewing 3 posts - 1 through 3 (of 3 total)

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