MSSQL has a nice function to replace null values conditinally
ISNULL(columnName, newValue)
This function requires two parameter columnName and new value to be replaced in place of null.
This function help me alot to solve the problem at database level instead at the coding level.
June 4, 2007 at 5:13 am |
In mysql, we can use
COALESCE(field,value)
SELECT firstName, COALESCE(lastName, ‘Last Name Not Specified’) FROM info
March 6, 2008 at 1:34 pm |
Cool, exactly what I need.
Thank You
May 8, 2008 at 3:13 pm |
@Vijay Thanks for that comment. I was looking for an alternative for ISNULL since someone commented on one of my blog posts that I should use it. Unfortunately MySQL and MSSQL did the function differently and this is what I was looking for.