- 注册时间
- 2011-3-21
- 最后登录
- 2022-3-22
- 在线时间
- 1191 小时
- 阅读权限
- 200
- 积分
- 9457
- 帖子
- 1256
- 精华
- 0
- UID
- 1
|
假设有主题表:topic, 评论表:comment
comment.topic_id 外键参照了 topic.id
查询按主题ID排序SQL:- SELECT comment.*, topic.id AS tid
- FROM comment, topic
- WHERE comment.topic_id=topic.id
- ORDER BY topic.id
复制代码 .
ASP 查询代码示例- <%
- Dim sql
- sql = "SELECT comment.*, topic.id AS tid FROM comment, topic WHERE comment.topic_id=topic.id ORDER BY topic.id"
- ' conn 为己打开的 ADODB.Connection 对象
- Set rs = conn.Execute(sql)
- ' 遍历 rs
- While Not rs.EOF
- ' 使用查询结果, rs("id").Value, rs("tid").Value, rs("content").Value ....
- ' ....
-
- rs.MoveNext
- Wend
- rs.Close
- Set rs = Nothing
- %>
复制代码 |
|