On 3/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

I am running a basic install of MySQL 5.0 with "strict mode" turned on  I
would like to use RPAD however at times a NULL var will be sent to the
function. My goal is to have a function that will convert the NULL to a
blank string to get the result of EXAMPLE3 if a NULL is returned.


EXAMPLE 1

mysql> select rpad(null,5,'1');
+------------------+
| rpad(null,5,'1') |
+------------------+
| NULL             |
+------------------+
1 row in set (0.00 sec)


Try this:

SELECT RPAD(CASE WHEN NULL IS NULL THEN '' ELSE '2' END, 5, '1');

If you are using it on an actual field, you would replace the first NULL and
the '2' with the field to be checked.

Reply via email to