Re: Delete query

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Uri Dimant (urid_at_iscar.co.il)
Date: 03/09/04


Date: Tue, 9 Mar 2004 12:34:04 +0200

simon
If you are concered about performance and you have a large set of data ,so
you can consider using WHERE NOT EXISTS /EXISTS clause for such subqueries.

"simon" <simon.zupan@stud-moderna.si> wrote in message
news:#RRhKEcBEHA.3400@tk2msftngp13.phx.gbl...
> I have 2 tables with columns: ID,countryID and date.
>
> I would like to delete all rows in table T1 which id and country id exists
> also in table T2 after specific date.
>
> This works (I think) but is there any other query with better perforamnce,
> some kind of join?
>
> DELETE * FROM T1 WHERE T1.ID IN (SELECT ID FROM T2 WHERE date>@date)
> AND T1.countryID IN (SELECT country ID FROM T2 WHERE date>@date)
>
> Thank you,
> Simon
>
>



Relevant Pages

  • Re: Easy question on UPDATE
    ... See Example C under UPDATE in Books Online, and also "Changing Data ... Using the FROM Clause". ... Simon ... Prev by Date: ...
    (comp.databases.ms-sqlserver)
  • Re: Update queries using more than one table
    ... See Example C under UPDATE in Books Online, and also "Changing Data ... Using the FROM Clause". ... Simon ... Prev by Date: ...
    (comp.databases.ms-sqlserver)
  • Re: Easy question on UPDATE
    ... Simon Hayes wrote: ... >See Example C under UPDATE in Books Online, and also "Changing Data ... >Using the FROM Clause". ...
    (comp.databases.ms-sqlserver)
  • Re: Speed of SQL Query
    ... It is also a good practice to not use * with SELECT clause if ... > Which of the following would be quicker? ...
    (microsoft.public.sqlserver.programming)
  • Re: Bizarre subquery syntax problem
    ... you've made change to a query or Access itself has made change to ... MVP - Technologies Virtual-PC ... I have been forced into using subqueries a lot, ... trouble accessing aliases defined in the FROM clause in the WHERE or ORDER ...
    (microsoft.public.access.queries)