Re: [sqlite] Re: delete/update joins

2007-12-01 Thread Joe Wilson
--- Igor Tandetnik <[EMAIL PROTECTED]> wrote:
> Joe Wilson  wrote:
> > delete from table1 where rowid in (
> >  select table1.rowid
> >from table2
> >   where table1.id = table2.id
> > and table2.otherid = 1
> > );
> 
> Why not just
> 
>  delete from table1 where id in (
>   select id from table2
>where table2.otherid = 1
>  );

Yep, I missed that.

But in the (admittedly unlikely) event that table1 was small 
and table2 had billions of rows and otherid had low cardinality
or otherid was not indexed, while id was indexed in both tables,
then the first form could be more efficient.   ;-)




  

Get easy, one-click access to your favorites. 
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Re: delete/update joins

2007-12-01 Thread Igor Tandetnik

Joe Wilson  wrote:

This may be better:

delete from table1 where rowid in (
 select table1.rowid
   from table2
  where table1.id = table2.id
and table2.otherid = 1
);


Why not just

delete from table1 where id in (
 select id from table2
  where table2.otherid = 1
);

Igor Tandetnik

-
To unsubscribe, send email to [EMAIL PROTECTED]
-