SQL 用于字符串连接的 SQLite 更新语法?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1446125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 03:41:07  来源:igfitidea点击:

SQLite Update Syntax for string concatenation?

sqlsqlitesyntaxstring-concatenation

提问by Snowy

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?

连接字符串的正确语法是什么?

回答by Ben S

SQLite's string concatenation operatoris "||", not "+"

SQLite 的字符串连接运算符是“ ||”,而不是“ +

UPDATE TestTable SET description = 'desc of ' || name;