Simon, can you expand your syntax, or are you just saying, "get x,y,z  store
them in a set of variables, then run update with appropriate bindings"?

Hopefully this related question isn't called hijacking a thread. I feel this
belongs together under set multiple values using the update query.

I'm toying with something similar, and don't want to get the run multiple
updates so that the C code can stay simple.

create table x (sn int primary key , comboid, property1 int , property2 int
, property3 int ...)
create table dictionary  (comboid int primary key, property1 int , property2
int, property3 int

(original insert into x was sn, comboid=-1 /*a flag to indicate this needs
an update*/ with property 1, 2, and 3 being correct. The original insert was
honking, very slow thing that I've given up hope of salvaging  since the
below beats it 10 to 100:1 in speed)

want to update each sn with the comboid from the dictionary where property1,
2, and 3 match.

currently I'm leaning on
insert or replace into x (sn, comboid, property1, property2, property3)
values select x.sn, d.comboid, x.property1, x.property2, x.property3 from x
inner join dictionary d on
x.property1 =d.property1 and x.property=d.property2 and  x.property3
=d.roperty3
where x.comboid=-1;

This somehow feels like cheating, though it seems to produce an acceptable
result quickly enough (on my relatively small db)

Adam



On Sun, May 9, 2010 at 5:23 PM, Simon Slavin <slav...@bigfraud.org> wrote:

>
> On 9 May 2010, at 8:41pm, Simon Hax wrote:
>
> > I think in sqlite the following is not possible:
> >
> > update T
> >      set (a,b,c) = ( select x,y,z from ...)
> >
> > Does anyone know how to do in an easy way ?
>
> Do your SELECT first, then set the multiple variables to the values
> retrieved from that:
>
> UPDATE T SET a=x,b=y,c=z WHERE ...
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
VerifEye Technologies Inc.
905-948-0015x245
7100 Warden Ave, Unit 3
Markham ON, L3R 8B5
Canada
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to