Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String concatenation does not work in SQLite

People also ask

How do I concatenate in DB browser SQLite?

The general syntax of using the concatenate operators in SQLite is: SELECT "string1" || " " || "string2"; The explanation of this syntax is: Use the SELECT clause to retrieve the data.

How do you concatenate null values in SQL?

One way to concatenate multiple strings or columns is to use the "+" operator. For the rows where MiddleName is NULL, the concatenation result will be NULL.

What are the three arguments for the substr () function in SQLite?

SQLite substr() returns the specified number of characters from a particular position of a given string. A string from which a substring is to be returned. An integer indicating a string position within the string X. An integer indicating a number of characters to be returned.


Try using || in place of +

select  locationname || '<p>' from location;

From SQLite documentation:

The || operator is "concatenate" - it joins together the two strings of its operands.


The || operator is the concatenation in SQLite. Use this code:

select  locationname || '<p>' from location;

For comparison,

SQLite                      ||  
Oracle                      CONCAT(string1, string2) or ||
MySQL                       CONCAT(string1, string2, string3...) or || if PIPES_AS_CONCAT enabled
Postgres                    CONCAT(string1, string2, string3...) or ||
Microsoft SQL Server 2012+  CONCAT(string1, string2, string3...) or + 
Microsoft Access            +  

for Visual Studio 2010, using the Data Sources designer or wizard, you're in trouble using || operator. Create a view in the sqlite db and create your data source(s) from that.

See also this thread.