a large update query

a large update query

am 07.07.2005 17:49:21 von Mark Mchugh

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@m.gmane.org

Re: a large update query

am 07.07.2005 18:02:20 von SGreen

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

Mark Mchugh 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_=--

Re: a large update query

am 07.07.2005 19:47:39 von Mark Mchugh

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



cheers

MArk

--- SGreen@unimin.com wrote:

> Mark Mchugh 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@m.gmane.org

RE: a large update query

am 11.07.2005 08:58:57 von jbonnett

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@yahoo.com]=20
Sent: Friday, 8 July 2005 3:18 AM
To: SGreen@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@unimin.com wrote:

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



=09
____________________________________________________
Sell on Yahoo! Auctions - no fees. Bid on great items. =20
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@m.gmane.org