How can I cast something that returns NULL to 0?
If this is my query: select col from table; would this be the right way to do it: select cast(col as unsigned integer) from table;?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’d probably want to use the
COALESCE()function:COALESCE()returns the first non-NULLvalue in the list, orNULLif there are no non-NULLvalues.Test case:
Result: