最新汽车维修资料:SQL查询语句的疑问

来源:百度文库 编辑:高考问答 时间:2024/04/30 03:48:22
现在有表SORT
字段
ID SORTNAME CSORTNAME
1 害虫 蚊子
2 害虫 蟑螂
3 害虫 苍蝇
4 食物 牛肉
5 食物 羊肉
6 害虫 蚂蚁
现在如何执行SQL查询语句,使得....循环输出同类项的数据...不同类之间用RESPONSE.WRITE隔开

sql="select * from sort order by SORTNAME"

......
str1=""
while not rs.eof
if str1<>"" and str1<>rs("SORTNAME") then
response.write "-------------<br>"
end if
str1=rs("SORTNAME")
response.write rs("CSORTNAME")

rs.movenext
wend
rs.close

你可以用一个ID字段来定义种类,然后再用循环读的方法读出各个ID字段上的实物,再在字段上加一,然后继续读