我想更新下表中的中ArticleId为2和3中的KeyWords分别为‘东风’,‘商用车’,请问怎么做啊?
实际数据库中有几天条数据库,我需要的是sql语句,请不要用存储过程,谢谢了create table AC_Article
(
ArticleId int,
IsEnable bit,
IsPublish bit,
KeyWords varchar(100)
)insert into AC_Article
select 1,'true','true','联合卡车,卡车' union all
select 2,'true','true',NULL union all
select 3,'false','false','' union all
select 4,'true','true','联合卡车,搅拌车,自卸,轻卡'
实际数据库中有几天条数据库,我需要的是sql语句,请不要用存储过程,谢谢了create table AC_Article
(
ArticleId int,
IsEnable bit,
IsPublish bit,
KeyWords varchar(100)
)insert into AC_Article
select 1,'true','true','联合卡车,卡车' union all
select 2,'true','true',NULL union all
select 3,'false','false','' union all
select 4,'true','true','联合卡车,搅拌车,自卸,轻卡'
(
ArticleId int,
IsEnable varchar(10),
IsPublish varchar(10),
KeyWords varchar(100)
)insert into AC_Article
select 1,'true','true','联合卡车,卡车' union all
select 2,'true','true',NULL union all
select 3,'false','false','' union all
select 4,'true','true','联合卡车,搅拌车,自卸,轻卡' update AC_Article set KeyWords = (case when ArticleId = 2 then '东风' when ArticleId = 3 then '商用车' else KeyWords end)select * from AC_Articledrop table AC_Article/*ArticleId IsEnable IsPublish KeyWords
----------- ---------- ---------- ----------------------------------------------------------------------------------------------------
1 true true 联合卡车,卡车
2 true true 东风
3 false false 商用车
4 true true 联合卡车,搅拌车,自卸,轻卡(所影响的行数为 4 行)
*/
3要商用车 ?为什么?告诉我为什么?why?
select '上汽,依维柯' union
select '福田' union
select '陕汽' union
select '东风' union
select '陕汽,重卡' union
select '商用' union
select '依维柯' union
select '上汽,依维柯,红岩' union
select '商用车' union
select '商用车,发动机' union
select '重卡' union
select '货车' union
select 'NULL' union
select '燃油' union
select '超载,计重' union
select '牵引车,挂车' union
select '中华' union
select '黄标车' union
select '轻卡' union
select '卡车,自卸车' union
select '潍柴,发动机' union
select '零部件' union
select '制动器' union
select '康明斯' union
select '法士特,变速器,客车' union
select '内燃机' union
select '潍柴' union
select '一汽解放,变速器' union
select 'NULL' union
select '中国重汽,威伯科' union
select '柴油机' union
select '商用车' union
select '零部件,新能源' union
select '客车,变速器' union
select '新能源' union
select '新能源' union
select '潍柴' union
select '福伊特' union
select '商用车,福田' union
select '货车' union
select '货车,轻卡' union
select '专用车' union
select '庆铃,轻卡' union
select '轻卡' union
select '重卡,自卸车' union
select '轻卡' union
select '解放,奥威' union
select '斯堪尼亚' union
select '红岩,依维柯,重卡' union
select '五十铃,轻卡' union
select '陕汽' union
select '依维柯' union
select '陕汽' union
select '江淮,轻卡' union
select '东风,轻卡' union
select '中国重汽' union
select '重卡' union
select '跃进,轻卡' union
select '跃进,欧卡,索菲姆,发动机' union
select '日野,重卡' union
select '中国重汽,重卡' union
select '庆铃,轻卡' union
select '货运车,载重车,GPS' union
select '重卡' union
select '重卡' union
select 'NULL' union
select '重卡' union
select '依维柯' union
select '货运车' union
select '商用车' union
select '东风,天龙' union
select '轻卡' union
select '东风,龙卡' union
select '重卡' union
select '商用车,专用车,卡车' union
select '斯堪尼亚,保时捷,卡车' union
select '商用车' union
select 'NULL' union
select '商用车' union
select '陕汽' union
select '商用车' union
select 'NULL' union
select '杰狮' union
select 'NULL' union
select 'NULL' union
select '重汽' union
select '重卡' union
select '杰狮' union
select '广汽,商用车' union
select '商用车' union
select '卡车' union
select '货车' union
select '黄标车' union
select '中国重汽' union
select '上汽,依维柯' union
select '重卡' union
select '西欧,卡车' union
select '重卡' union
select '卡车,沃尔沃' union
select '卡车' union
select '卡车' union
select '卡车' union
select 'NULL' union
select '卡车' union
select '德龙,牵引车' union
select '奔驰,卡车' union
select '德龙,重卡' union
select '解放,新大威,牵引车' union
select '红岩' union
select '卡车' union
select '变速器' union
select '中国重汽,卡车' union
select '东风,霸龙' union
select '卡车' union
select '重卡,发动机' union
select 'NULL' union
select '曼恩' union
select '柴油' union
select '柴油机' union
select 'NULL' union
select '轮胎' union
select 'NULL' union
select '斯太尔' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select '' union
select 'NULL' union
select '自卸车' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select '' union
select 'NULL' union
select '离合器' union
select '自卸车' union
select '解放' union
select '东风,重卡,天锦' union
select '东风,轻卡' union
select '东风,皮卡' union
select '陕汽,德龙' union
select '庆铃,重卡' union
select '江铃,轻卡,凯瑞' union
select '大众,皮卡' union
select '五十铃,客车' union
select '江铃,轻卡' union
select '江淮,格尔发' union
select '欧曼,重卡' union
select '日产,轻卡' union
select '斯堪尼亚' union
select '华菱' union
select '红岩,重卡' union
select '中国重汽,重卡' union
select '奔驰,牵引车' union
select '重卡,牵引车' union
select '沃尔沃,重卡' union
select '日野,重卡' union
select '依维柯,红岩,杰狮,重卡' union
select 'NULL' union
select '欧马可,康明斯,发动机' union
select '货车,挂车' union
select '自卸车' union
select '载货车' union
select '专用车,挂车' union
select '货车' union
select '货车' union
select '罐式车' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select '新能源' union
select '柳汽' union
select '杰狮,红岩' union
select '江淮,轻卡' union
select '轻卡' union
select '商用车' union
select '商用车' union
select '商用车' union
select '重卡' union
select '雷诺,卡车' union
select '卡车' union
select '卡车' union
select 'NULL' union
select '奔驰,卡车' union
select '卡车' union
select '卡车' union
select '轮胎' union
select 'NULL' union
select 'NULL' union
select '货车' union
select '黄标车,货车' union
select 'NULL' union
select '燃油' union
select '货车' union
select '货车' union
select 'NULL' union
select '东风,轻型车' union
select '长城' union
select '中兴,威虎,皮卡' union
select '轻卡' union
select '东风,重卡,天锦' union
select '皮卡,江铃' union
select '福特,皮卡' union
select '柴油,皮卡' union
select '福特,皮卡' union
select '大众,皮卡' union
select '三菱,皮卡' union
select '铃木,皮卡' union
select '丰田,皮卡' union
select '皮卡' union
select 'NULL' union
select '发动机' union
select '斯太尔,发动机' union
select '卡车' union
select '油罐车' union
select '斯太尔,发动机' union
select '卡车' union
select '卡车' union
select '沃尔沃,卡车' union
select '锡柴,奥威' union
select '陕汽,德龙' union
select '牵引车' union
select '卡车' union
select '沃尔沃' union
select '雷诺' union
select '解放' union
select '江铃,皮卡' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select 'NULL' union
select '欧曼' union
select '解放' union
select 'NULL' union
select '豪沃' union
select '卡车' union
select '依维柯' union
select '货车' union
select '沃尔沃,卡车' union
select '汉诺威,曼,卡车' union
select '重卡' union
select '重汽,曼,沃尔沃' union
select '商用车' union
select '专用车' union
select '商用车' union
select '福田' union
select '陕汽' union
select '陕汽,新能源,重卡' union
select '陕汽,新能源,重卡' union
select '中国重汽' union
select '江铃' union
select '重卡' union
select 'NULL' union
select '重卡' union
select 'NULL' union
select 'VOLVO,牵引车' union
select '柴油机' union
select '商用车,变速器' union
select 'NULL' union
select '商用车,柴油机' union
select '重卡' union
select '卡车' union
select '重卡' union
select '重卡' union
select '自卸车' union
select 'GPS' union
select '华菱,重卡' union
select '米其林' union
select '依维柯,红岩' union
select '中国重汽' union
select '曼,商用车' union
select '北奔,卡车' union
select '奔驰,卡车' union
select '沃尔沃,卡车' union
select '依维柯' union
select 'NULL' union
select '江淮' union
select '康明斯' union
select '一汽解放' union
select '东风,商用车' union
select '沃尔沃,卡车' union
select '福特,卡车' union
select '沃尔沃,卡车' union
select '皮卡' union
select '福特,皮卡' union
select '福特' union
select '重卡' union
select 'NULL' union
select '重卡' union
select '轻卡' union
select '' union
select 'NULL' union
select 'NULL' union
select '江淮' union
select '卡车' union
select '江淮' union
select '上汽,依维柯,红岩,杰狮' union
select '福田,欧曼' union
select '卡车,沃尔沃' union
select '沃尔沃,重卡' union
select '霸龙,欧曼' union
select '红岩' union
select '青年曼卡' union
select '华菱,重卡' union
select '红岩' union
select '德龙' union
select '奔驰' union
select '曼,重卡' union
select '重卡' union
select '牵引车' union
select '北奔' union
select '柳汽,霸龙' union
select '重卡' union
select '福田,欧曼' union
select '柴油,奥铃' union
select '郑州日产,皮卡' union
select '皮卡'
from 表A a ,表B b where a.id=b.id
begin tranbegin tryupdate xxxx
commit tran
end try
begin catch
rollback tran
end catch