SQLite Update Syntax for string concatenation?

24,953

SQLite's string concatenation operator is "||", not "+"

UPDATE TestTable SET description = 'desc of ' || name;
Share:
24,953

Related videos on Youtube

Snowy
Author by

Snowy

Updated on July 09, 2022

Comments

  • Snowy
    Snowy almost 2 years

    I have a table with this data

    id , name    , description
    1  , apple   , ''
    2  , orange  , ''
    

    I am trying to pass the following statement to update the row so the description column is 'desc of apple' and 'desc of orange' but it is not working.

     Update TestTable Set description = 'desc of ' + name 
    

    What is the proper syntax to concatenate strings?

  • yantrab
    yantrab almost 15 years
    + is not standard SQL syntax for string concatenation.
  • Kibbee
    Kibbee almost 15 years
    Is there a standard SQL Syntax for string concatenation? It seems every DB uses a different one. MySQL Uses Concat() function, SQL Lite using ||, SQL Server Uses +. Definitely something that should be standardized.
  • Amit Naidu
    Amit Naidu over 8 years
    Yes, there is a standard SQL syntax. It is ||, adopted in the SQL-92 standard ISO/IEC 9075:1992. It's just that SQL Server and MySQL chose not to comply with the standard. Although MySQL can be coaxed by setting PIPES_AS_CONCAT