


Now let us try to concatenate the first name and the last name.ĬONCAT(first_name,' ',last_name)full_nameĬonsidering the null values in a table, let us understand how concatenation works with null values. Let us consider a table with the following values. Now let us try to understand how concatenation works with table values. Let us take a simple example using the string literals. Concatenation ParametersĬONCAT Parameters – The only required parameters are the string values that need to be concatenated separated by a comma.Īddition Operator Parameters – It does not require anything more than the strings separated by a comma that needs to be concatenated.ĬONCAT_WS Parameters – The first parameter is the separator that you want to use, after that all the strings that are being concatenated are added, all separated by a comma. Let us take one more look at the parameters that we pass into the CONCAT function. So you can use either of these approaches to concatenate strings in SQL. SELECT CONCAT_WS("-", "EDUREKA", "SQL") Take a look at an example below to understand how it works. To separate the strings with a separator, we can use CONCAT_WS() function as well. We can use the addition “+” operator to add two or more strings together. Let’s say we have the same strings “edureka” and “SQL”, to concatenate these two strings we will write the following command. It works the same with the CONCAT function as well. And if we concatenate these two strings, we will get a resultant string or concatenated string as “edureka SQL”. So ideally concatenation works like- let’s say we have two strings, “edureka”, “SQL”. To understand how we can use CONCAT in SQL, let us take a simple example. The CONCAT function can take up to 255 input strings for concatenation. The CONCAT function will implicitly convert those values before the concatenation. If at all, non-character string values are passed as input. There has to be at least two strings as input for the CONCAT function to work without any hassles. The CONCAT function raises an error if only one string is passed as input. There are a few things you should keep in mind while using the CONCAT function. In SQL, the concatenation of strings is achieved by the CONCAT() function. The following topics are covered in this blog: In this article, we will learn how we can use the CONCAT() function in SQL. It takes up to 255 input strings and joins them together. In SQL, this is achieved by a function named CONCAT(). Concatenation, in general, refers to binding a bunch of strings into a single string.
