Thread: Re: [GENERAL] Dynamic update

Re: [GENERAL] Dynamic update

From
Alain TESIO
Date:
-- Simon Drabble <simon@eskimo.com> wrote:
> Is it possible to update a column with another column's value, say
>
> UPDATE member SET votes = `SELECT count(votes) FROM ballot WHERE id
> = 1`;
>
> with or without aggregates?

Have you tried a more direct command ?

UPDATE member SET votes count(votes) FROM ballot WHERE id = 1 ;

(I can't test right now but I don't see why this wouldn't work ...)

Alain

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

Re: [GENERAL] Dynamic update

From
Simon Drabble
Date:
On Wed, 3 Nov 1999, Alain TESIO wrote:

> -- Simon Drabble <simon@eskimo.com> wrote:
> > Is it possible to update a column with another column's value, say
> >
> > UPDATE member SET votes = `SELECT count(votes) FROM ballot WHERE id
> > = 1`;
> >
> > with or without aggregates?
>
> Have you tried a more direct command ?
>
> UPDATE member SET votes count(votes) FROM ballot WHERE id = 1 ;
>
> (I can't test right now but I don't see why this wouldn't work ...)
>
> Alain


I get parse error at or near count - any variation (without the = sign)
produces a similar error.

TA,

Simon.

>
> __________________________________________________
> Do You Yahoo!?
> Bid and sell for free at http://auctions.yahoo.com
>

--
 "Linux - open doors, not windows."

   Simon Drabble                      It's like karma for your brain.
   simon@eskimo.com


Re: [GENERAL] Dynamic update

From
"Aaron J. Seigo"
Date:
hi...

just tested this:

> UPDATE member SET votes count(votes) FROM ballot WHERE id = 1 ;
>
> (I can't test right now but I don't see why this wouldn't work ...)

genisys=> UPDATE members SET phone1 = deadmem.phone1 FROM deadmem WHERE deadmem.id_num = 7356 and
genisys-> members.id_num = 100;
UPDATE 1

with an '=' and defining which field belongs to which table it works! =)  kudos
to alain...

--
Aaron J. Seigo
Sys Admin

Re: [GENERAL] Dynamic update

From
Simon Drabble
Date:
On Wed, 3 Nov 1999, Aaron J. Seigo wrote:

> hi...
>
> just tested this:
>
> > UPDATE member SET votes count(votes) FROM ballot WHERE id = 1 ;
> >
> > (I can't test right now but I don't see why this wouldn't work ...)
>
> genisys=> UPDATE members SET phone1 = deadmem.phone1 FROM deadmem WHERE deadmem.id_num = 7356 and
> genisys-> members.id_num = 100;
> UPDATE 1
>
> with an '=' and defining which field belongs to which table it works! =)  kudos
> to alain...
>
> --
> Aaron J. Seigo
> Sys Admin
>


Thanks Aaron (and others), that got it - I was missing the table. part of the
column specifier, and also I was trying to update an empty table - oops.

I knew there had to be a way - thanks once again.

Simon


--
 "Linux - open doors, not windows."

   Simon Drabble                      It's like karma for your brain.
   simon@eskimo.com