■■■■■一个sql子查询的问题,怎样用动态数组替代子查询语句来提高速度

hlm750908 2004-08-28 05:54:28
xx="select 字段1 from 表1 where 字段1 in (select 字段11 from 表2)"
xx="select 字段111 from 表3 where 字段1 in (" & xx & ")"

怎样用动态数组来替换 in 后的语句


...全文
278 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hlm750908 2005-01-31
  • 打赏
  • 举报
回复
大家帮忙

XmagicX 2004-09-12
  • 打赏
  • 举报
回复
原始的省事省力啊
cqm2099 2004-09-12
  • 打赏
  • 举报
回复
up
northwolves 2004-09-12
  • 打赏
  • 举报
回复
xx = "select 字段111 from 表3 where 字段1 in (select 字段1 from 表1 where 字段1 in (select 字段11 from 表2))"

就可以,用数组不见得更快
hlm750908 2004-09-12
  • 打赏
  • 举报
回复
up
fishmans 2004-08-29
  • 打赏
  • 举报
回复
dim str as string
dim arraya() as string
dim i as integer
redim arraya(10) as string
for i=0 to 10
arraya(i)="a"+cstr(i)
str=str+"'"+arraya(i)+"',"
'注意:如果为数值型 的就不要加那两个'号
next

str= left(str,len(str)-1)
xx="select 字段111 from 表3 where 字段1 in (" & str & ")"
Andy__Huang 2004-08-28
  • 打赏
  • 举报
回复
xx="select 字段1 from 表1 where 字段1 in (select 字段11 from 表2)"
這個句子寫得很好,你的動態數組數據是從哪時來的?如果從數據庫裡出來那就不必了。


用數組:
dim arr as varient
dim sss as string
sss="............."
arr=split(sss,",")
xx="select 字段111 from 表3 where 字段1 in (" & arr & ")"
請你試用第二種方法一下

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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