On 14 March 2011 15:42, Gary wrote:
> I have a table in a mysql db that has 3 columns that I want to insert
> (update) data if the row&column is empty (IS NULL). However I want to start
> at the first column, if this column is not null, then move to insert the
> data into column 2, if that is empty, then insert data into column 3.
>
> I have been looking over the manual and boards but am not finding a
> solution.
>
> Can anyone point me in the right direction.
>
> --
> Gary
>
>
>
> __ Information from ESET Smart Security, version of virus signature
> database 5952 (20110314) __
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You would have to code it.
I'm not a mysql guru (MSSQL is what I use), but ...
UPDATE
Table
SET
Column3 = CASE
WHEN
Column3 IS NULL
AND
Column2 IS NOT NULL
AND
Column1 IS NOT NULL
THEN
Value
ELSE
Column3
END,
Column2 = CASE
WHEN
Column2 IS NULL
AND
Column1 IS NOT NULL
THEN
Value
ELSE
Column2
END,
Column1 = CASE
WHEN
Column1 IS NULL
THEN
Value
ELSE
Column1
END
WHERE
IDColumn = ID
something like that?
--
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php