What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?

MySQLMySQLi Database

<h2 style="">NULL as both arguments</h2><p>MySQL returns blank output if we will use NULL as both of the arguments in CONCAT_WS() function.</p><h3 style="">Example</h3><pre class="prettyprint notranslate" style="">mysql&gt; Select CONCAT_WS(&#39;&#39;,NULL,NULL); +-------------------------+ | CONCAT_WS(&#39;&#39;,NULL,NULL) | +-------------------------+ | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | +-------------------------+ 1 row in set (0.00 sec)</pre><h2 style="">NULL as one of the argument</h2><p>MySQL returns the value of the other argument as output if we will use NULL as one of the argument in CONCAT_WS() function.</p><h3 style="">Example</h3><pre class="prettyprint notranslate" style="">mysql&gt; Select CONCAT_WS(&#39;&#39;,NULL,&#39;Delhi&#39;); +----------------------------+ | CONCAT_WS(&#39;&#39;,NULL,&#39;Delhi&#39;) | +----------------------------+ | Delhi &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| +----------------------------+ 1 row in set (0.00 sec) mysql&gt; Select CONCAT_WS(&#39;&#39;,&#39;Ram&#39;,NULL); +--------------------------+ | CONCAT_WS(&#39;&#39;,&#39;Ram&#39;,NULL) | +--------------------------+ | Ram &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| +--------------------------+ 1 row in set (0.00 sec)</pre><h2 style="">NULL at the place of separator</h2><p>MySQL returns NULL as output if we will use NULL at the place of the separator in CONCAT_WS() function.</p><h3 style="">Example</h3><pre class="prettyprint notranslate" style="">mysql&gt; Select CONCAT_WS(NULL, &#39;NEW&#39;,&#39;DELHI&#39;); +--------------------------------+ | CONCAT_WS(NULL, &#39;NEW&#39;,&#39;DELHI&#39;) | +--------------------------------+ | NULL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | +--------------------------------+ 1 row in set (0.00 sec)</pre>
raja
Updated on 20-Jun-2020 08:37:20

Advertisements