通过添加后缀来更新列 [英] Update column by adding a suffix

查看:103
本文介绍了通过添加后缀来更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下给出的一些数据



产品表



I have some data with given below

Product table

ProductID	ProductName	             SupplierID
1	           Chai    	                1
2	           Chang	                1
3	           Aniseed Syrup	        1
9	           Mishi Kobe Niku  	        4
10	           Ikura	                4
11	           Queso Cabrales	        5
12	           Queso Manchego La Pastora	5
74	           Longlife Tofu	        4









我想根据条件更新表格,并在给定的'Where'条件下为列值添加后缀

如下所示

我想通过将v.1字符串附加到列值来更新那些具有1和4作为供应商ID的记录





I want to update the table on a criteria and append a suffix to the column values on the given 'Where' condition
as shown below
I want to update those record who have 1 and 4 as supplier id by appending v.1 string to the column value

ProductID	ProductName	       SupplierID
1	           Chai .v1    	          1
2	           Chang.v1	          1
3	           Aniseed Syrup.v1	  1
9	           Mishi Kobe Niku.v1  	  4
10	           Ikurav.14	          4







Declare
@Suffix varchar(10)='v.1'
Update Product
set ProductName=(select ProductName from Product where SupplierID in (1,4)+@Suffix)
where
where SupplierID in (1,4)



但是我知道工作。请帮助


But it wont work . Please help

推荐答案

update product set productname = productname + '.v1'
where supplierid in (1, 4);
select * from product


这篇关于通过添加后缀来更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆