在sqlite sum字符串中连接字符串

时间:2014-07-07 01:33:13

标签: sql sqlite

我在sql中有这个语法:

UPDATE fazerbem_carrinho_historico 
SET pendencia_pago = '10.00', 
    pendenciahistorico = pendenciahistorico + '12' 
WHERE data_compra = '76'

假设在pendenciahistorio列中已经有'16'值,应该发生什么,因此我提供更新,存储值1612,但它们保存{{1}的总和1}},因为16 + 12列是一个varchar,怎么解决它?

2 个答案:

答案 0 :(得分:4)

||运算符在SQLLite中用于 连接 字符串:

UPDATE fazerbem_carrinho_historico 
SET pendencia_pago = '10.00', 
    pendenciahistorico = pendenciahistorico || '12' 
WHERE data_compra = '76'

答案 1 :(得分:0)

对于字符串连接,请使用||

UPDATE fazerbem_carrinho_historico
    SET pendencia_pago = '10.00',
        pendenciahistorico = pendenciahistorico || '12'
    WHERE data_compra = '76';