注册 登录
编程论坛 ASP技术论坛

[求助]如何取出含有变量的几位数值?

shy0000 发布于 2007-09-13 17:55, 1178 次点击

有表为A,有字段为B,B中有001、009512、006412125、001021……这样的不规则数字

现在a为变量,其值为0,我想求出第一位含a变量值的4位数

where b like 'a___'
想使用这样的语句,求出以变量a开始的4位数,但不能成功,a=0,提示为a变量名无效

只能使用where b like '0___' 这样才能成功

使用WHERE B like a??这条语句时,出现count字段不正确的提示。
难道变量不能在这里使用??

[此贴子已经被作者于2007-9-14 11:56:44编辑过]

14 回复
#2
盖世豪侠2007-09-13 18:29

[此贴子已经被作者于2007-9-13 20:56:26编辑过]

#3
shy00002007-09-13 18:57
我希望创建一个记录集,在条件中进行设置
#4
shaoli42612007-09-13 19:03
str=mid(rs("B").value,1,3)
这个应该能实现吧~~~~
#5
shy00002007-09-13 19:43

就是含有变量a的值,只需位数为4位的

[此贴子已经被作者于2007-9-13 23:12:53编辑过]

#6
盖世豪侠2007-09-13 20:53

[此贴子已经被作者于2007-9-13 20:56:07编辑过]


#7
shy00002007-09-14 00:02
where b like 'a____1'
想使用这样的语句,求出以变量a开始的4位数,但不能成功,a=0
#8
madpbpl2007-09-14 00:40

where b like 'a___%'
三个_

#9
shy00002007-09-14 10:01
楼上的不能成功
提示:
a是一个无效的变量名称
#10
盖世豪侠2007-09-14 10:02
where b like '001*'

[此贴子已经被作者于2007-9-14 10:07:05编辑过]

#11
盖世豪侠2007-09-14 10:08
当用不了 where b like '001*'

就改用 where b like '001%'
#12
shy00002007-09-14 11:45
楼上的,你没有把变量a放进来
#13
YSKING2007-09-14 12:18

<%
dim n0,n1,n2,a
a=0
n0=rs("B")
n1=InStr(n0,a)
if n1=1 then
n2=len(n0)
if n2=4 then
response.write "这个四位数为:"&n0
end if
end if
%>

#14
madpbpl2007-09-14 20:10
where b like '" &amp; a &amp; "___%'
#15
盖世豪侠2007-09-14 21:03
where b like '"&amp;a&amp;"*'

[此贴子已经被作者于2007-9-14 21:04:40编辑过]


1