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
From: Mike Johnson [mailto:[EMAIL PROTECTED]
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
- Original Message -
From: Martin Rytz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 10, 2004 9:45 AM
Subject: Suppress the 0 value
Hi MySQL-Users
I have a simple select statement like 'select id from table'. The result
is
0, becaues the id field is 0
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