Normally If You concate One String Value With NULL values means That Returns NULL value only or some time that Query result not came.To Prevent this by use of "ISNULL(....)" Statement.
Example:
SELECT CONCAT(ID,ISNULL(NAME,' ')) FROM TABLE_NAME WHERE CONDITION
In that ISNULL checks the NAME .The Value of NAME is NULL means replace Empty String and concat with ID and return result.Otherwise it returns Actual value of NAME and concat with ID and return result.
You Can also use "COALESCE" instead of "ISNULL" .Both Doing Same action only.
It also Work in HQL.
Example:
SELECT CONCAT(ID,ISNULL(NAME,' ')) FROM TABLE_NAME WHERE CONDITION
In that ISNULL checks the NAME .The Value of NAME is NULL means replace Empty String and concat with ID and return result.Otherwise it returns Actual value of NAME and concat with ID and return result.
You Can also use "COALESCE" instead of "ISNULL" .Both Doing Same action only.
It also Work in HQL.
No comments:
Post a Comment