如何取得一个字符串的前几位数?

tsting 2001-07-06 01:38:02
我这样写对吗?
select sum(xsje) into :xsje from table where table.gz like :la
我想查出在gz的前面4位等于变量la的值。
...全文
139 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangsw 2001-07-06
  • 打赏
  • 举报
回复
数组:
好象不行!!
不行呀!
wangsw 2001-07-06
  • 打赏
  • 举报
回复
这样做呀:
select sum(xsje) into :xsje from table where substring(table.gz,1,4)=:la ;
OK?!!
tsting 2001-07-06
  • 打赏
  • 举报
回复
lay变量可以用数组吗?
:la可以写成:la[i]吗?
咖啡 2001-07-06
  • 打赏
  • 举报
回复
两种方法都行.
还是用:
string la
la = 你的条件字符串(长度为4的那个)
la += '%'
select sum(xsje) into :xsje from table where table.gz like :la;
好一点.
一定要记得加上'%'
iamxia 2001-07-06
  • 打赏
  • 举报
回复
同意
szjlq 2001-07-06
  • 打赏
  • 举报
回复
sql server:
select sum(xsje) into :xsje from table where substring(table.gz,1,4)=:la

sqlanywhere
select sum(xsje) into :xsje from table where substr(table.gz,1,4)=:la

1,076

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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