Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70

    Unanswered: Problem - DELETE FROM

    I have 3 tables

    TABLE_1: ID, Flag, Other fields................
    TABLE_2: ID, Other fields......................
    TABLE_3: ID, Other fields.........................

    The relation is like this

    TABLE_1 ---> TABLE_2 ---> TABLE_3 (The key is ID)


    I want to
    DELETE from TABLE_3
    WHERE
    TABLE_1.ID='something' AND TABLE_1.Flag = 'something'

    The field Flag is in Table_1

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    it would be something like

    delete a
    from table3 a , table1 b
    where a.id = b.id and whatever conditions you want on table 1
    Last edited by Enigma; 03-09-04 at 09:29.
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Feb 2002
    Location
    Sweden
    Posts
    34
    Shouldn´t this work?

    Delete
    Table_3
    From
    Table_1 t1
    inner join Table_2 t2 on (t1.ID = t2.ID)
    inner join Table_3 t3 on (t2.ID = t3.ID)
    Where
    t1.Flag = 'something'
    - Jonte

  4. #4
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70
    Thanks Jonte,
    It is working

  5. #5
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Originally posted by Jonte
    Shouldn´t this work?

    Delete
    Table_3
    From
    Table_1 t1
    inner join Table_2 t2 on (t1.ID = t2.ID)
    inner join Table_3 t3 on (t2.ID = t3.ID)
    Where
    t1.Flag = 'something'
    You dont need to join table2 until you need some flag from it
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  6. #6
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70
    Enigma, Yes you are right.
    Your example is more efficient, I will use your example.

Posting Permissions

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