求一语句,马上揭贴

hoxisoft 2004-04-21 09:19:05
我有个字段A是是VARCHAR型的,长度是21,里面存着手机号如:13012345678
另一个字段S是INT型的,长度是4,存的是手机号开始号段如:1300000
另一个字段E是INT型的,长度是4,存的是手机号结束号段如:1300000

我现在想判断A是否在S和E之间,怎么写这个SQL呢?????
...全文
46 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
azsoft 2004-04-21
  • 打赏
  • 举报
回复
在查询分析器里ctrl+T进行测试
hoxisoft 2004-04-21
  • 打赏
  • 举报
回复
我们经理说一快

我不知道哪个快哦,哈哈
internetcsdn 2004-04-21
  • 打赏
  • 举报
回复
我想是二快吧
hoxisoft 2004-04-21
  • 打赏
  • 举报
回复
大家看看下面两个方案哪个执行效率会高些,数据大约在200WAN条


一:

update SMSBilling_MTv2 set area=unicomseg.Province from SMSBilling_MTv2,unicomseg
where SMSBilling_MTv2.tomobilenumber>=(convert(varchar,unicomseg.StartNum)+'0000')
and SMSBilling_MTv2.tomobilenumber<=(convert(varchar,unicomseg.EndNum)+'9999')

二、

update SMSBilling_MTv2 set area=unicomseg.Province from SMSBilling_MTv2,unicomseg
where SubString(SMSBilling_MTv2.tomobilenumber,1,7) between unicomseg.StartNum and unicomseg.EndNum

JerryOne 2004-04-21
  • 打赏
  • 举报
回复
select * from YourTable where SubString(A,1,7) between s and e
hoxisoft 2004-04-21
  • 打赏
  • 举报
回复
我现在想UPDATE,,大家看我这样行吗???

update SMSBilling_MTv2 set area=unicomseg.Province from SMSBilling_MTv2,unicomseg
where SMSBilling_MTv2.tomobilenumber>=unicomseg.(convert(varchar,StartNum)+'0000')
and SMSBilling_MTv2.tomobilenumber<=unicomseg.(convert(varchar,EndNum)+'9999')
zjcxc 元老 2004-04-21
  • 打赏
  • 举报
回复
select * from 表 where left(字段A,7) between s and e
BigInt 2004-04-21
  • 打赏
  • 举报
回复
select * from tablename
where left(s,4) between left(cast(s as varchar(10)),4) and left(cast(e as varchar(10)),4)
hoxisoft 2004-04-21
  • 打赏
  • 举报
回复
selecet area,sum(CAST(FeeInfo1 AS DECIMAL(38, 3)))
from SMSBilling_MTv2
where FeeType=02 and ReportStatus=0 group by area

有什么不对吗,,总提示:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'CAST'.

34,587

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧