On 03/08/07, Nikola Miljkovic <[EMAIL PROTECTED]> wrote:
> [In the message "Re: [sqlite] Re: Re: how do i declare and use variables in 
> sqlite?" on Aug 3, 11:47, "Paul Harris" writes:]
> > > >> create temporary table vars (name text, value something);
> > > >> --
> > > >> insert into vars set name="x", value=0;
> > > >> --
> > > >> ... where something = (select value from vars where name="x")...
> > > >>
> > > >
> > > > I tried doing this, but there doesn't seem to be a way to do the same
> > > > thing with an UPDATE command ?
> > >
> > > No way to do what with UPDATE command? What exactly are you trying to
> > > do, and failing?
> > >
> >
> > i've just realised the last statement ("...where etc etc") is probably
> > supposed to be part of a select statement.
>
> Yeap, sorry for being "too conceptual", dislexic (insert/update, thanks Igor)
> and obviously too confusing :-).
>
>
> > anyway, this is what i'm trying to do:
> >
> > eg 1
> > select @somevar := column1 from table1;
> > update table2 set column2 = @somevar;
>
> Try:
>
> create temporary table var1 select column1 from table1;
> update table2 set column2 = (select column1 from var1);
>
> As written the second comand will likely not do what was intended
> since var1 might have more than 1 row and there is no constraint
> so every row in table2 will be affected. I assume that real
> implementation will deal with this.
>

ok, so a subselect can be used.   not bad, but not as powerful as the
mysql @ variables, which can then be used in all sorts of scenarios
later, without inducing the same query over and over to get the value.

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

Reply via email to