How can CONCAT() function be applied on columns of MySQL table?

MySQLMySQLi Database

<p>We can use CONCAT() function to combine the values of two or more columns. In this case, the arguments of the CONCAT() functions would be the name of the columns. For example, suppose we have a table named &lsquo;Student&rsquo; and we want the name and address of the student collectively in one column then the following query can be written &minus;</p><pre class="prettyprint notranslate">mysql&gt; Select Id, Name, Address, CONCAT(ID,&#39;, &#39;,Name,&#39;, &#39;, Address)AS &#39;ID, Name, Address&#39; from Student; +------+---------+---------+--------------------+ | Id &nbsp; | Name &nbsp; &nbsp;| Address | ID, Name, Address &nbsp;| +------+---------+---------+--------------------+ | 1 &nbsp; &nbsp;| Gaurav &nbsp;| Delhi &nbsp; | 1, Gaurav, Delhi &nbsp; | | 2 &nbsp; &nbsp;| Aarav &nbsp; | Mumbai &nbsp;| 2, Aarav, Mumbai &nbsp; | | 15 &nbsp; | Harshit | Delhi &nbsp; | 15, Harshit, Delhi | | 20 &nbsp; | Gaurav &nbsp;| Jaipur &nbsp;| 20, Gaurav, Jaipur | +------+---------+---------+--------------------+ 4 rows in set (0.00 sec)</pre>
raja
Updated on 30-Jan-2020 07:20:26

Advertisements