Mysql coalesce() function recognition and usage

coalesce recognition: return the first non-empty expression in the parameter (from left to right)

Similar to oracle's nav() function, but not in mysql, it can be replaced by this function. The advantage of coalesce compared to nvl is that there can be multiple parameters in coalesce, while there are only two parameters in nvl(). Of course, case when....then....else...end can also be used in oracle (more powerful, case when can be followed by an expression.

 

Instructions:

 

select coalesce(a,b,c) from temp

 explain:

 

If a!=null, return a, if a==null, return b, if b==null, return c; if both abc are null, return null

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326316622&siteId=291194637