Hi, Trey.

I checked not implemented features list of sqlite and found nothing
about "update ... from".

There's no "FROM" on http://www.sqlite.org/lang_update.html, so that's a hint that it's not supported. All the same, maybe this should be added to
http://www.sqlite.org/omitted.html

update table1 set val = ss.v
from
(select t2.some as v, t1.id as id
from table1 t1, table2 t2
where t1.id = t2.nid) as ss
where ss.id = table1.id

How about

update table1
 set val =
 (select some from table2
  where table1.id = table2.nid
 );

- TMack

It works. Thanx. Sometimes this approach it's too slow, sometimes it
doesn't works but I can go ahead now :).

Hello, I wish to propose another statement, though it does not look so attractive. But sure it is fast:

insert or replace into table1 (rowid, id, val2, val)
select t1.rowid, t1.id, t1.val2, t2.some
from table1 t1
left outer join table2 t2 on t2.id = t1.nid;

This is equivalent to the update statement, assuming:
1. table1 has no primary key (so rowid is used)
2. table1 has no further columns as the ones mentioned (id, val and val2)

The outer join is added fot complete equivalence. It arranges that "val" gets assigned null where no matching row is found in table2. If that is not desirable, this can be omitted to leave singular rows unchanged.

Hope this is useful, Ed Pasma






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

Reply via email to