[thelist] [mysql] + operator (solved)

Paul Bennett paul at teltest.com
Sun Feb 2 19:00:17 CST 2003


Please ignore this post - I had a dicky duplicate db record which was
screwing things up - the query does work as I had it

<tip type="mysql">
To update a numeric field in your mysql database, simply use the "+"
operator to add the new value to the old
for example:
"update $tableName set value=value+$newValue where id='$id' limit 1";
if the old value was '2' and the $newValue was 3.5, the value will now
be set to 5.5

To add new values to the end of a text field in your mysql database, use
the cocatenation operator
for example:
"update $tableName set value=CONCAT(value, '$newValue') where id='$id'
limit 1";
If the old value was "php" and the $newValue was "is the best web
programming language", the value will now be set to "php is the best web
programming language" ;)
</tip>

>
--
Paul Bennett
Internet Developer
Teltest Electronic Design
--------------------------
Phone : 64 4 237 0767
Web : http://www.teltest.com
Wap : http://wap.teltest.com
Email : paul at teltest.com
--------------------------






More information about the thelist mailing list