你好我是SQL新手,我想使用Case语句。SQL中的案例陈述
我现在有这条SQL语句
update tblAccount set FullName = rtrim(isnull(FirstName,''));
update tblAccount set FullName = FullName + ' ' + rtrim(MI)
where substring(reverse(MI),1,1)='.';
update tblAccount set FullName = FullName + ' ' + rtrim(MI) + '.'
where substring(reverse(MI),1,1)!='.'
and MI is not null and len(rtrim(MI)) = 1;
update tblAccount set FullName = FullName + ' ' + rtrim(MI)
where len(rtrim(MI)) >= 2;
update tblAccount set FullName = FullName + ' ' + LastName;
update tblAccount set FullName = FullName + ', ' + Suffix
where Suffix is not null
and len(rtrim(Suffix)) > 0;
我想这个转换成一些更小,更易于阅读,有人告诉我一个Case语句可能会帮助,但我familar有了它,我在想,如果任何人都可以帮助将其转换为更具可读性的内容。
您使用的是SQL Server吗?甲骨文? MySQL的?答案可能因此而异。 –