Thread: Delete Question

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    1
    Rep Power
    0

    Delete Question


    Hi everybody,

    I want to delete records from one table that meet certain criteria from more than one table.

    Something like

    Delete

    from table_1
    where field.table_1 =....
    and field.table_2 = ....

    I'm afraid to have "from table_1, table_2" because I don't want to delete anything from table 2, only table 1.

    I was successfully able to select all the data I wanted to delete, now I just need to delete them. Is there I way I can modify that successful SELECT table by inserting a line or two?

    Thank you so much for your help.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,643
    Rep Power
    4247
    Something like this:
    Code:
    DELETE FROM t1
    FROM table1 AS t1
    INNER JOIN table2 AS t2
    ON t1.field1 = t2.field2
    AND t1.field3 = ...
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo