×
☰ See All Chapters

MySQL CONCAT Function

MySQL CONCAT function adds two or more arguments together. In Oracle this function is equivalent to the concatenation operator (||).

MySQL CONCAT Function Syntax

CONCAT(arguement1, arguement2, arguement3,...)

arguement1, arguement2, arguement3: These arguments can be an expression or a direct value or a value from a column of any type. If all arguments are non-binary strings, the result is a non-binary string. If the arguments include any binary strings, the result is a binary string. If a numeric argument is given then it is converted to its equivalent non-binary string form.

MySQL CONCAT Function Example

Creating table for demonstrating CONCAT Function

CREATE TABLE NAME

(

  FNAME  VARCHAR(10 )    NOT NULL,

  LNAME  VARCHAR(10 )

);

Insert into NAME (FNAME, LNAME) Values ('ADI', 'TEMP');

Insert into NAME (FNAME, LNAME) Values ('NAVEEN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('HARISH', 'GOWDA');

Insert into NAME (FNAME, LNAME) Values ('HARI', 'PRASAD');

Insert into NAME (FNAME, LNAME) Values ('ARJUN', 'SHETTY');

Insert into NAME (FNAME, LNAME) Values ('KIRAN', 'KUMAR');

COMMIT;

Example 1

SELECT CONCAT(FNAME, ' ', LNAME) AS FULL_NAME

FROM NAME;

mysql-concat-function-0

Example 2

SELECT CONCAT(FNAME, 'Hello') AS FULL_NAME

FROM NAME;

mysql-concat-function-1


All Chapters
Author