易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL取值问题 - MS-SQL Server / 基础类

表table 

  A B
  12*2+10*5
  4*3+10*4
  15*2+81*4

如何取B列中第一个*号前的数,并赋给A列
--search
SQL code:
select left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1)


--update

SQL code:
update table
set a = left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1)


select left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1) > 0


update table set a = left(b,charindex('*',b)-1) from table where left(b,charindex('*',b)-1) > 0


SQL code:

update 表table set A=left(B,charindex('*',B)-1)


都是牛人啊。

没多少分,呵呵,权当意思下。新手。。不好意思。


相关问答:

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

关于SQL语句OR的问题 - Oracle / 高级技术

通过NAME字段条件查询一个数据表,假设我有100个姓名,有以下两个方法,
方法1:
把100个Name 组成一个SQL语句,比如 Select * from tmp_table where Name='张三' or Name ='李四' Or ...Or Name='第一百个姓名'
......

sql语句问题 - Java / Web 开发

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号