MySQL query default value is query is NULL

Problem when wanting to mapping values from MySQL query to Object in JAVA but MySQL Query returns NULL
If Application is written in spring boot with JDBCTemplate and mapping to Object, the exception will occur.

org.springframework.beans.TypeMismatch…


This content originally appeared on DEV Community and was authored by goffity

Problem when wanting to mapping values from MySQL query to Object in JAVA but MySQL Query returns NULL
If Application is written in spring boot with JDBCTemplate and mapping to Object, the exception will occur.

org.springframework.beans.TypeMismatchException

can be solved by use IFNULL

SELECT IFNULL(emp_id,0) FROM emp WHERE 1=0;

Output

0

Reference:
https://dev.mysql.com/doc/refman/5.7/en/flow-control-functions.html
https://www.w3schools.com/sql/func_mysql_ifnull.asp


This content originally appeared on DEV Community and was authored by goffity


Print Share Comment Cite Upload Translate Updates
APA

goffity | Sciencx (2021-07-05T16:41:35+00:00) MySQL query default value is query is NULL. Retrieved from https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/

MLA
" » MySQL query default value is query is NULL." goffity | Sciencx - Monday July 5, 2021, https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/
HARVARD
goffity | Sciencx Monday July 5, 2021 » MySQL query default value is query is NULL., viewed ,<https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/>
VANCOUVER
goffity | Sciencx - » MySQL query default value is query is NULL. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/
CHICAGO
" » MySQL query default value is query is NULL." goffity | Sciencx - Accessed . https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/
IEEE
" » MySQL query default value is query is NULL." goffity | Sciencx [Online]. Available: https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/. [Accessed: ]
rf:citation
» MySQL query default value is query is NULL | goffity | Sciencx | https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.