读书人

想把一个sql语句分成两个过程来实现

发布时间: 2012-10-18 13:46:56 作者: rapoo

想把一个sql语句分成两个过程来实现,怎么处理啊
[code=VB][/code]
Conn
sql = "select distinct xiaoqu_name as 小区名称 from user_data where xiaoqu_name not in(select distinct a.xiaoqu_name from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='" & cmbSelinfo.Text & "' where readtime>'" & DateAdd("d", -6, Date) & "' and readtime < '" & DateAdd("d", 1, Date) & "') and selinfo='" & cmbSelinfo.Text & "' order by xiaoqu_name asc"
Debug.Print sql
rs.Open sql, cnn, 1, 1

怎么处理啊。想把这句SQL语句分成两个过程实现

[解决办法]
sql = "select distinct a.xiaoqu_name from user_data as a inner join readdata as b on a.remote_id=b.remote_id and a.selinfo='" & cmbSelinfo.Text & "' where readtime>'" & DateAdd("d", -6, Date) & "' and readtime < '" & DateAdd("d", 1, Date) & "'"

Debug.Print sql

rs.Open sql, cnn, 1, 1

strInSub = rs.GetString(2, , , ",")

sql = select distinct xiaoqu_name as 小区名称 from user_data where xiaoqu_name not in( & strInSub & ") and selinfo='" & cmbSelinfo.Text & "' order by xiaoqu_name asc"

Debug.Print sql

rs.Open sql, cnn, 1, 1

读书人网 >VB

热点推荐