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

From: Date: Tue, 11 May 2004 11:07:59 +0000
Subject: Re: Replacing field values in MySQL - is there an easy way?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-23668@lists.php.net to get a copy of this message
Just use: UPDATE table SET fld1= 'foobar' WHERE some-condition or RTM... =) .bobo ----- Original Message ----- From: "Ross Honniball" <ross@bookshop.jcu.edu.au> To: <php-windows@lists.php.net> Sent: Tuesday, May 11, 2004 12:40 PM Subject: [PHP-WIN] 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. > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.windows (#23668) next »