高分求ASP数据查询问题

来源:百度知道 编辑:UC知道 时间:2024/05/07 06:30:00
高分求ASP数据表查询问题
网站用ACCESS+ASP

两个表如下,通过ncid关联
A表
ncid class blocka
1 中国 11
2 法国 11
...
n ... 1n
B表
id ncid title content blockb time
1 1 查 无 11
2 1 地 无 11
3 2 二 无 11

要求,先从B中查询出最新blockb=11,5条新闻,在对应A中class字段,在把A表中class字段合并过来.

id class ncid title content blockb time
1 中国 1 查 无 11
...

select 怎么写,麻烦高手贴出来,高分追加.

呵呵 联表查询语句有点长

你试试看~~

select top 5 id ,class, ncid ,title, content, blockb ,time from B表 join A表 on B表.ncid =A表.ncid where blockb=11 order by time desc

联表查询的关键字是join on 还有左联接 右连接

top 5 就是根据时间最新的5条 当然还有order by time desc这句 desc是降序 asc是升序

select top 5 b.*,a.class where a.ncid=b.ncid and b.blockb=11 这样不行?