MySQL CONCAT() Function

The CONCAT() function combines two or more expressions (strings) into one string.

Tutorials dojo strip

MySQL CONCAT Function Syntax

SQL

MySQL CONCAT Function Example

This query returns the combined string 'SQL Tutorial is fun!'.

SQL

Note: The CONCAT() function is supported in MySQL but not in SQLite. This example does not work in the TechKubo playground. You can use || (string concatenation operator) in SQLite instead.

MySQL CONCAT Function Parameters

ParameterDescription
expression1, expression2, …Required. The expressions to add together. If any expression is NULL, the result will be NULL.

MySQL CONCAT Function Table Column Example

This query returns the full name of each patient by combining the first_name and last_name columns.

SQL

Note: The CONCAT() function is supported in MySQL but not in SQLite. This example does not work in the TechKubo playground. You can use first_name || ‘ ‘ || last_name in SQLite instead.

MySQL CONCAT Function Notes

  • Combines multiple expressions into one string.
  • If any expression is NULL, the result will be NULL.
  • Works in MySQL 4.0 and higher.
  • Not supported in SQLite. In SQLite, use || (double pipe) for string concatenation.

Tutorials dojo strip