2013-07-16 47 views
0

在数据库中,product_description对于名为custom_title(vchar)的列有一些空的值。 我想用另一个名为“name”和文本的值(vchar)更新它。 我想,返回0:如果你想更新你需要使用一个更新语句,而不是选择将一列与mysql中的文本结合起来

SELECT name + 'text' AS custom_title 
FROM product_description 
where custom_title is NULL 
+1

要连接字符串在我的SQL,请使用['CONCAT'](http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat)函数:'SELECT CONCAT(name,'text')AS custom_title ...' –

回答

2
SELECT concat(name ,'text') AS custom_title FROM product_description where custom_title is NULL 

...

update product_description 
    set custom_title = concat(name ,'text') 
    where custom_title is NULL 

做大写的拳头字母...

SELECT concat(upper(substring(name, 0,1)),substring(name, 2) ,'text') AS custom_title 
    FROM product_description where custom_title is NULL 
+0

自定义标题为空不为空,我已将其修改为:where custom_title =''。但它显示了结果,但不保存它们。 custom_title colomn仍然是emty。 –

+0

@valentin_da_valentinv我让你更新声明... –

+0

谢谢,它的工作原理。现在我知道:) –

相关问题