Re: Basic Update query
am 10.02.2006 13:07:52 von Jonathan
Tony Wainwright wrote:
> Hi guys
>
> I'm pretty new to mysql and was just wondering if you can update multiple
> fields at the same time i.e:
> UPDATE tablename SET field1 = value1 AND field2 = value 2 etc... WHERE
> field0 = value;
>
> Cheers
> Tony
>
>
Yes, you this is possible... but you can also use the following syntax:
UPDATE tablename (field1, field2, ..., fieldn) SET VALUES (value1,
value2, ..., valuen) WHERE field0 = value;
Jonathan
Re: Basic Update query
am 10.02.2006 18:12:10 von gordonb.vtfun
>I'm pretty new to mysql and was just wondering if you can update multiple
>fields at the same time i.e:
>UPDATE tablename SET field1 = value1 AND field2 = value 2 etc... WHERE
>field0 = value;
Yes, but you don't use AND, you use a comma to separate different
field assignments.
I think the statement as you gave it would work, but it would only
set field1, and it would do some funky boolean calculations for
its value:
UPDATE tablename SET field1 = ((value1) AND (field2 = value2)) WHERE
^ assignment ^comparison
field0 = value;
Instead use:
UPDATE tablename SET field1 = value1, field2 = value2, ... WHERE
field0 = value.
Gordon L. Burditt