asp访问access数据库分类

来源:百度知道 编辑:UC知道 时间:2024/05/04 11:25:41
是一个企业网站,产品分大类,然后小类,点小类再显示产品
数据库结构是
A表大类名sID,B表包含了A的大类 类xID 还有表C产品uid
我去页面显示的时候用到了3次查询类别,这样影响服务器,请教有没有一次读完或者二次读完的方式呢,请举例或者有类似的代码发到我jack0959@qq.com谢谢了,据说通过视图方式可以更好解决...

用一个表存储产品分类信息,大概结构
P_id, P_name ,P_parent_id
1 , 产品1 , 0
2 , 产品2 , 0
3 , 产品3 , 0
4 , 产品11 , 1
5 , 产品21 , 2

然后用一个循环取出产品类
sql=“select*from pro where P_parent_id=0”'P_parent_id等于0为大类
if rs.eof then
do while not rs.eof
response.write(rs("P_name"))
sql_small=“select*from pro where P_parent_id=”&rs("P_id")'取出P_id大类对应的小类
if rs_small.eof then
do while not rs_small.eof
loop
end if
loop
end if