2017青岛9月秋季车展:asp SELECT语句问题,在线等

来源:百度文库 编辑:神马品牌网 时间:2024/04/26 21:04:37
randid=int(rnd*500+1) '随机生成的整数
Set rs = Server.CreateObject ("ADODB.Recordset")
sql = "Select * from 002 where timu_id=3"
rs.Open sql, conn,2,3

上面是我的代码,我现在想实现 随机选择timu_id的效果,我想知道怎么让timu_id=randid 啊? SQL语句格式不大熟悉,不知道怎么把外部定义的变量放进来,谢谢。

sql = "Select * from 002 where timu_id="&randid
timu_id为数字 不带'号 而且即便是字符串类型也得用引号把这个变量包起来例如 sql = "Select * from 002 where timu_id=' & randid & "'"

sql = "Select * from 002 where timu_id='"&randid
即可