Summary: in this tutorial, you will learn how to use the concat() function and concatenation operator (||) and to concatenate two strings into a string.
Introduction to SQLite concat() function
In SQLite, the concat() function allows you to concatenate multiple strings into a single string. Here’s the syntax of the concat() function:
concat(s1, s2, ...);In this syntax:
s1,s2, .. are the strings that you want to concatenate.
The concat() function returns a string that is the result of concatenating the input strings.
The concat() function treats NULL as an empty string. If all the input strings are NULLs, the concat() function returns an empty string.
SQLite concat() function examples
Let’s take some examples of using the concat() function.
1) Basic concat() function example
The following example uses the concat() function to concatenate two strings into a string:
SELECT concat('SQLite', ' Concat') result;Code language: JavaScript (javascript)Output:
result
-------------
SQLite ConcatThe following statement uses the concat() function to concatenate three strings into a single string:
SELECT concat('SQLite',' ','Concat') result;Code language: JavaScript (javascript)Output:
result
-------------
SQLite Concat2) Using concat() function with table data
We’ll use the employees table from the sample database.