a large update query

Hi all,
I have an update query that could update each item in
a row, is there a quick way to do this , i.e. not have
to use set for each item in the list?


many thanks





____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.
http://auctions.yahoo.com/

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32 [at] m.gmane.org
Mark Mchugh [ Do, 07 Juli 2005 17:49 ] [ ID #869908 ]

Re: a large update query

--=_alternative 00586F4A85257037_=
Content-Type: text/plain; charset="US-ASCII"

Mark Mchugh <mark_mch [at] yahoo.com> wrote on 07/07/2005 11:49:21 AM:

> Hi all,
> I have an update query that could update each item in
> a row, is there a quick way to do this , i.e. not have
> to use set for each item in the list?
>
>
> many thanks
>
You do not need to create a new statement for each column, if that's what
you are asking. Just put a list of the column changes all in the same
statement separated by commas

UPDATE foobar SET col1 = 6, col3 = 15, col18 = col3+col1, ...(the rest of
the columns)... ;

Now when I design a multicolumn update like this I tend to format it with
each column on it's own line, like this:

UPDATE foobar
SET col1 = 6
, col3 = 15
, col18 = col3+col1
, ...(the rest of the columns)... ;

That way I can see what I am going to change by scanning the left side of
the list.

If you are asking: Is there a way to automatically update each column
without specifying the actual columns and their new values

The answer would be "no".

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
--=_alternative 00586F4A85257037_=--
SGreen [ Do, 07 Juli 2005 18:02 ] [ ID #869909 ]

Re: a large update query

thanks Shawn, was trying to get out of writing a long
statement........



cheers

MArk

--- SGreen [at] unimin.com wrote:

> Mark Mchugh <mark_mch [at] yahoo.com> wrote on 07/07/2005
> 11:49:21 AM:
>
> > Hi all,
> > I have an update query that could update each item
> in
> > a row, is there a quick way to do this , i.e. not
> have
> > to use set for each item in the list?
> >
> >
> > many thanks
> >
> You do not need to create a new statement for each
> column, if that's what
> you are asking. Just put a list of the column
> changes all in the same
> statement separated by commas
>
> UPDATE foobar SET col1 = 6, col3 = 15, col18 =
> col3+col1, ...(the rest of
> the columns)... ;
>
> Now when I design a multicolumn update like this I
> tend to format it with
> each column on it's own line, like this:
>
> UPDATE foobar
> SET col1 = 6
> , col3 = 15
> , col18 = col3+col1
> , ...(the rest of the columns)... ;
>
> That way I can see what I am going to change by
> scanning the left side of
> the list.
>
> If you are asking: Is there a way to automatically
> update each column
> without specifying the actual columns and their new
> values
>
> The answer would be "no".
>
> Shawn Green
> Database Administrator
> Unimin Corporation - Spruce Pine




____________________________________________________
Sell on Yahoo! Auctions – no fees. Bid on great items.
http://auctions.yahoo.com/

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32 [at] m.gmane.org
Mark Mchugh [ Do, 07 Juli 2005 19:47 ] [ ID #869910 ]

RE: a large update query

Depending on what you are doing you might be able to construct the long
SQL statement you need programmatically.

John Bonnett

-----Original Message-----
From: Mark Mchugh [mailto:mark_mch [at] yahoo.com]
Sent: Friday, 8 July 2005 3:18 AM
To: SGreen [at] unimin.com
Cc: mysql list
Subject: Re: a large update query

thanks Shawn, was trying to get out of writing a long
statement........



cheers

MArk

--- SGreen [at] unimin.com wrote:

> Mark Mchugh <mark_mch [at] yahoo.com> wrote on 07/07/2005
> 11:49:21 AM:
>
> > Hi all,
> > I have an update query that could update each item
> in
> > a row, is there a quick way to do this , i.e. not
> have
> > to use set for each item in the list?
> >
> >
> > many thanks
> >
> You do not need to create a new statement for each
> column, if that's what
> you are asking. Just put a list of the column
> changes all in the same
> statement separated by commas
>
> UPDATE foobar SET col1 =3D 6, col3 =3D 15, col18 =3D
> col3+col1, ...(the rest of
> the columns)... ;
>
> Now when I design a multicolumn update like this I
> tend to format it with
> each column on it's own line, like this:
>
> UPDATE foobar
> SET col1 =3D 6
> , col3 =3D 15
> , col18 =3D col3+col1
> , ...(the rest of the columns)... ;
>
> That way I can see what I am going to change by
> scanning the left side of
> the list.
>
> If you are asking: Is there a way to automatically
> update each column
> without specifying the actual columns and their new
> values
>
> The answer would be "no".
>
> Shawn Green
> Database Administrator
> Unimin Corporation - Spruce Pine



=09
____________________________________________________
Sell on Yahoo! Auctions - no fees. Bid on great items.
http://auctions.yahoo.com/


--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=3Dgcdmw-win32 [at] m.gmane.org
jbonnett [ Mo, 11 Juli 2005 08:58 ] [ ID #874320 ]
Datenbanken » gmane.comp.db.mysql.windows » a large update query

Vorheriges Thema: odd problem when sending an SQL
Nächstes Thema: installation problem of Windows Mysql server