You could use the IF() function and key off of the id value like this:

SELECT if(id=0, null, id) as id, if(id=0,null, field2) as field2, if(id=0, 
null, field3) as field3
FROM tablename

However, if you don't want any rows with 0 as an ID, you take care of that 
in the WHERE clause

SELECT id
FROM tablename
WHERE id <> 0

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

"Martin Rytz" <[EMAIL PROTECTED]> wrote on 11/10/2004 09:45:05 AM:

> 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?
> 
> Thank you in advance,
> Martin Rytz

Reply via email to