Categories: MySQL Functions

MySQL CONCAT() Functions – String Functions

MySQL CONCAT() Functions: Syntax

CONCAT ( string1, string2, ..  )

MySQL CONCAT() Functions: Description

CONCAT() functions returns the concatenated string. You may have one or more arguments.

  • If all arguments are nonbinary strings, the result is a nonbinary string.
  • If the arguments include any binary strings, the result is a binary string.
  • A numeric argument is converted to its equivalent nonbinary string form.
  • CONCAT() returns NULL if any argument is NULL.

For quoted strings, concatenation can be performed by placing the strings next to each other.


MySQL CONCAT() Functions: Parameter

[table caption=”” width=”100%” colwidth=”15%||30%|55%” colalign=”left|lef|left”]
Name, Required /Optional, Description
string1,  Required, first parameter is must.
string2 , Required, second parameter is must.
stringN… , Optional, N number of strings can be passed as parameter.
[/table]


MySQL CONCAT() Functions: Output

[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
NULL, if any argument is NULL.
nonbinary string, If all arguments are nonbinary strings.
binary string, If the arguments include any binary strings.
[/table]


MySQL CONCAT() Functions: Available from

[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 4.0
[/table]


MySQL CONCAT() Functions: Example 1

mysql> SELECT CONCAT('Tutorial', 'mines', '.net');
+-------------------------------------+
| CONCAT('Tutorial', 'mines', '.net') |
+-------------------------------------+
| Tutorialmines.net                   |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT CONCAT('Tutorial', NULL , 'mines', '.net');
+--------------------------------------------+
| CONCAT('Tutorial', NULL , 'mines', '.net') |
+--------------------------------------------+
| NULL |
+--------------------------------------------+
1 row in set (0.01 sec)

mysql> SELECT CONCAT(14.3, 12.45, 78.0);
+---------------------------+
| CONCAT(14.3, 12.45, 78.0) |
+---------------------------+
| 14.312.4578.0 |
+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT 'Tutorial' 'mines' '.net';
+-------------------+
| Tutorial |
+-------------------+
| Tutorialmines.net |
+-------------------+
1 row in set (0.00 sec)


Below is the mysql terminal screen for above code :


See all MySQL String functions MySQL 8 String Functions.


Related articles : LOCATE(), HEX(), CONCAT_WS(), LOWER(), LTRIM(), INSTR(), POSITION().


PHP Related articles : IMPLODE(), SUBSTR_COUNT(), SUBSTR_COMPARE(), PHP STRING FUNCTIONS(), JOIN().

jyoti rani

Recent Posts

From Tears to Toys: Exploring Modern Childhood through Delhi’s Favorite Toy Shop

In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…

1 day ago

Confused About Where to Buy Toys in India for your little one? We’ve Got You Covered

Looking for the perfect toy for your child can feel overwhelming with so many choices in today’s market. Whether you're…

2 days ago

A New Age of Play: Exploring the Magic of a Toy Shop in Delhi

In the heart of every child lies a world bursting with imagination — and the key to unlocking that world…

3 days ago

Creating Smiles with Play: The Magic of a Toy Store in Noida

In the fast-paced world of growing cities and digital lifestyles, children need spaces where their imagination is free to roam.…

4 days ago

A World of Wonder: Inside the Most Delightful Toy Store in Delhi

In a city as vibrant and diverse as Delhi, there’s a magic that lives beyond the monuments, food stalls, and…

5 days ago

The Magic of Play: Exploring the Best Toy Shop in Noida and Beyond

In the vibrant and rapidly developing city of Noida, playtime is getting smarter, more imaginative, and more inclusive than ever…

1 week ago