File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes SQL quetsion - how to 'convert' null to zero? (if statement) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL quetsion - how to Watch "SQL quetsion - how to New topic
Author

SQL quetsion - how to 'convert' null to zero? (if statement)

Peter Primrose
Ranch Hand

Joined: Sep 10, 2004
Posts: 755
hi all,
quick question: is there a possibility to return the value 0 and not NULL from the db?

example:
Select empl_id, age from myTable

result:
1 NULL
2 55

I would like to have:
1 0
2 55

thanks for any pointers
[ October 08, 2007: Message edited by: Peter Primrose ]
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
COALESCE(column_name,0)

Select empl_id, COALESCE(age,0)
from myTable


This will regardless RDBMS.
[ October 08, 2007: Message edited by: Paul Campbell ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQL quetsion - how to 'convert' null to zero? (if statement)