In SQL, CONCAT function is used to combine two or more strings together into a single string.
In SQL, A string is a data type used to store data that can contain combination of numbers, letters, whitespaces and symbols. In simple term, String is a word or a sequence of characters.
A substring is a consecutive sequence of characters or a portion of a string.
CONCAT(string1, string2, string3, ...)
• Specify the 'string' in single quotes ( ' ' ) or 'column' that you want to combine into a single string.
• There is no limit to the number of strings or columns that can be passed as arguments.
1. Let's assume we have a table named "[Employees]".
2. Let's assume you want to add 'dollar sign $' before each salary value.
3. Run below SQL statement :
SELECT CONCAT('$', Salary) FROM [Employees];
4. In above statement, CONCAT function combines the substring1 value 'dollar $' with all the values from the Salary column in substring2.
Using this function in a select statement won't modify the [Employees] table directly, but it will only be reflected in the select statement's output.
CONCAT function in SQL is used to combine two or more strings into a single string.
To concatenate 3 columns in SQL, use CONCAT function with the three column names separated by commas.
The CONCAT() function is used to concatenate strings in SQL, combining them into one.
In SQL, ||' '|| is a concatenation operator used to join two strings along with a space between them.