Preface Recently, I accidentally discovered MySQL's coalesce. I just had time, so I summarized the usage tips of coalesce() explained Returns the first non-empty expression in the argument (from left to right, and so on); Usage Examples There are three variables: a, b, and c. select coalesce(null,2,3); // Return 2 select coalesce(null,null,3); // Return 3 select coalesce(1,2,3); // Return 1 As can be seen from the above example, its function is to return the first non-null value in the passed parameter. SELECT COALESCE(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); -- Return 1 If all the passed parameters are null, null is returned, for example SELECT COALESCE(NULL, NULL, NULL, NULL); -- Return NULL This parameter is used when: if a field is null by default, and you want it to return something other than null, such as 0 or other values, you can use this function SELECT COALESCE(field name,0) as value from t; // (If the default value of the database commission field is not 0, it must be the developer's fault. Please don't criticize my personal opinion). Summarize The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Docker realizes the connection with the same IP network segment
>>: Swiper.js plugin makes it super easy to implement carousel images
The effect achievedImplementation Code html <d...
Table of contents introduce Support Intel CPU Sup...
Table of contents What is Docker Compose Requirem...
Table of contents 1. Data Source 2. Overall ranki...
Written in front No matter how well the code is w...
example: <html> <head> <style type...
I use Navicat as my database tool. Others are sim...
Bugs As shown in the figure, I started to copy th...
<style type="text/css"> Copy code ...
I want to achieve a situation where the width of ...
1. Check the firewall status Check the firewall s...
border-radius: CSS3 rounded corners Syntax: borde...
<br />Now let's take a look at how to cl...
When the scale of Docker deployment becomes large...
To solve the problem that Deepin cannot start Goo...