Results 1 to 5 of 5

Thread: Delete Query

  1. #1
    Join Date
    Apr 2004
    Posts
    13

    Unanswered: Delete Query

    Hey,
    I have the following problem in Delete query :
    1.I have two tables T,R with the same fields.
    2.I made a find without matching query from R to T to find the records in R that have no records in T.
    3.Now I want to delete the records from R that the query returned.
    I tried to do that by adding the matching query and R tables,and did the
    same steps in the help.
    Access give me the exeption Table delete didn't success)
    If some one can tell me the reson or write SQL command that to that.

    best regards...

  2. #2
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    100

    Re: Delete Query

    Originally posted by WasseemFarhat
    Hey,
    I have the following problem in Delete query :
    1.I have two tables T,R with the same fields.
    2.I made a find without matching query from R to T to find the records in R that have no records in T.
    3.Now I want to delete the records from R that the query returned.
    I tried to do that by adding the matching query and R tables,and did the
    same steps in the help.
    Access give me the exeption Table delete didn't success)
    If some one can tell me the reson or write SQL command that to that.

    best regards...
    I don't know if it works WassemFarhat, but you can try (where RPK and TPK are the corresponding primary keys). Or something like that, this idea but with the correct syntax, sorry.

    DELETE FROM R WHERE RPK NOT IN (SELECT TPK FROM T)

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Re: Delete Query

    Originally posted by WasseemFarhat
    Hey,
    I have the following problem in Delete query :
    1.I have two tables T,R with the same fields.
    2.I made a find without matching query from R to T to find the records in R that have no records in T.
    3.Now I want to delete the records from R that the query returned.
    I tried to do that by adding the matching query and R tables,and did the
    same steps in the help.
    Access give me the exeption Table delete didn't success)
    If some one can tell me the reson or write SQL command that to that.

    best regards...
    Try someting like that

    DELETE T.Field1
    FROM T
    WHERE T.Field1 In (SELECT R.Field1 FROM R);

  4. #4
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    1)
    Delete
    from tableA ta
    where NOT EXISTS
    (Select null
    from tableb
    where id = ta.id)
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    DELETE R
    FROM R LEFT JOIN T ON r.key = t.key
    WHERE t.key IS NULL

Posting Permissions

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