From: Martin Rytz [mailto:[EMAIL PROTECTED] 

> Hi MySQL-Users
>  
> I have a simple select statement like 'select id from table'. 
> The result is 0, becaues the id field is 0 (int-field).
>  
> My problem is now how to suppress the 0 and give NULL instead 
> of 0 as the result (i.E. everytime the result from the select 
> is 0 it should be NULL).
>  
> How can this be done within the select-statement?

SELECT IF(id = 1, NULL, id) AS id ...

The usage of IF() is IF(expression, true value, false value).


-- 
Mike Johnson             Smarter Living, Inc.
Web Developer            www.smarterliving.com
[EMAIL PROTECTED]   (617) 886-5539


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to