当前位置:编程学习 > C#/ASP.NET >>

谁帮我写一条sql 语句!!!!


  列1     列2    列3
 abcd      1      B
 bcde      2      A
 aaaa_A    2      A

在列1里面所有符合条件列3等于A的 都在列1后面加上_A 如果列1里面的值有_A的就不用加_A  --------------------编程问答-------------------- update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%A%' --------------------编程问答-------------------- update table set 列1=列1+'_A' where 列3='A' and charindex('_A',列1)=0 --------------------编程问答-------------------- --------------------编程问答-------------------- 直接用sql语句 不再。net怎么写 --------------------编程问答-------------------- 直接用sql

引用 1 楼 ssp2009 的回复:
update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%A%'


直接用sql语句怎么写 --------------------编程问答-------------------- 那不是sql语句是啥!!!!!!!

引用 5 楼 zhengweitao 的回复:
直接用sql

引用 1 楼 ssp2009 的回复:update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%A%'

直接用sql语句怎么写
--------------------编程问答--------------------
引用 6 楼 fangxuan 的回复:
那不是sql语句是啥!!!!!!!

引用 5 楼 zhengweitao 的回复:
直接用sql

引用 1 楼 ssp2009 的回复:update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%A%'

直接用sql语句怎么写


=号那有错误 --------------------编程问答-------------------- 检查你自己的sql与上述是否一致! --------------------编程问答--------------------
update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%_A%' 
--------------------编程问答--------------------
引用 9 楼 cnceohjm 的回复:
SQL code



1

update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%_A%'



这个就可以了, 楼主脑子有问题吧,这个就是SQL语句。 --------------------编程问答-------------------- 什么叫直接用sql语句。。。楼上的不都是sql语句吗 --------------------编程问答-------------------- LZ不认识SQL语句。。。。 --------------------编程问答--------------------
引用 4 楼 zhengweitao 的回复:
直接用sql语句 不再。net怎么写
 
 
第一步:查询'列1里面所有符合条件列3等于A,并且列1不是以_A结尾'的数据,这个时候返回的可能是一个DataSet
第二步:你可以循环读DataSet里DataTable的所有行,给这个表的实体类赋值,赋值的时候列1以string类型加上'_A'
第三步:数据库的Update.

笨办法.可以吗? --------------------编程问答--------------------
引用 4 楼 zhengweitao 的回复:
直接用sql语句 不再。net怎么写


我靠,你的意思是直接用SQL怎么写............... --------------------编程问答-------------------- lz说的是在.net里直接调用sql语句吗? --------------------编程问答-------------------- 这楼主问的真有意思 --------------------编程问答-------------------- 楼主好神奇,楼上的不都是sql语句吗?
--------------------编程问答-------------------- not like '%_A'  --------------------编程问答-------------------- update 表名 set 列1 = 列1+'_A' where 列1 like  '%'+列3+'%' and 列3='A'


我执行过了。没问题 --------------------编程问答-------------------- 除 --------------------编程问答-------------------- update tb set 列1=列1+'_A' where 列3='A' and 列1 not like '%A%'
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,