RE: Replacing field values in MySQL - is there an easy way?
| From: | Jattie van der Linde | Date: | Fri, 14 May 2004 08:51:29 +0000 |
| Subject: | RE: Replacing field values in MySQL - is there an easy way? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-23728@lists.php.net to get a copy of this message | ||
Update field, value where whatever
-----Original Message-----
From: Ross Honniball [mailto:ross@bookshop.jcu.edu.au]
Sent: Tuesday, May 11, 2004 11:40 AM
To: php-windows@lists.php.net
Subject: Replacing field values in MySQL - is there an easy way?
This is really a mySQL question, not a php question.
Say you just want to up-date (ie. REPLACE) the value of just one field
within a mysql record with many fields.
Is there a way to do it without tediously re-setting all the existing field
values?
eg.
You have a table with:
fld-name fld-value
-------------------
fld1 abc (PRIMARY KEY)
fld2 def
fld3 xzy
fld4 whatever
and you just want to change say fld4 to 'something else'.
The only way I can see to do it is by tediously setting up a query like:
REPLACE INTO table SET fld1='abc', fld2='def', fld3='xyz',
fld4='something
else'
if you try and say :
REPLACE INTO table SET fld1='abc', fld4='something else'
it sets fld2 and fld3 to null :-(.
Anyone know an easy way to get mysql to retain non-key values not
explicitly set in a replace call?
. Ross Honniball JCU Bookshop Cairns Supervisor
. James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
. Ph:07.4042.1157 Fx:07.4042.1158 Em:ross@bookshop.jcu.edu.au
. There are no problems. Only solutions.