Replacing field values in MySQL - is there an easy way?

From: Date: Tue, 11 May 2004 10:40:26 +0000
Subject: Replacing field values in MySQL - is there an easy way?
Groups: php.windows 
Request: Send a blank email to php-windows+get-23667@lists.php.net to get a copy of this message
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.

« previous php.windows (#23667) next »