[thelist] [mysql] concat problem [solved]

kris burford kris at midtempo.net
Wed Mar 30 08:42:33 CST 2005


>[snip]
>UPDATE mytable SET mycell = CONCAT(mycell, $FormResults) WHERE id=1
>
>which works fine, on the provision that mycell != null
>
>if mycell is null, then it doesn't work (returns 0 affected rows)
>
>anyone know how i can change this to work?
>[/snip]
>
>Use an IF (not tested, so syntax may be off)
>
>update mytable set mycell = if(mycell IS NULL, concat(mycell,
>$formresults), $formresults) where id=1
>  
>
fantastic. thanks jay.

although the other way around, just to be completist about it... ; )

UPDATE mytable SET mycell = IF(mycell IS NULL, $formresults, 
CONCAT(mycell, $formresults) where id = 1


More information about the thelist mailing list