This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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)
 
jQuery in Action, 3rd edition