这个多表查询每个表都能够按顺序把前两条数据查询出来,但我想每一个表查询都能按倒序排出来,那样每一个表更新的数据就能显示出来,按ID字段倒序排列,那个高手帮忙一下
rs.open"Select TOP 2 * from _xinwen union all Select TOP 2 * from _tiyu union all Select TOP 2 * from _yule union all Select TOP 2 * from _xiaohua union all Select TOP 2 * from _jiaocheng ",conn,1,1
这样可以做到:先在每个表中查询最后更新的记录(两条)
最后再将多个表组合成一个新表 as t,然后再在外层排列
dim orderby:orderby=" order by id desc "
dim sql
sql=" select * from ("
sql=sql=&" Select TOP 2 * from _xinwen "&orderby
sql=sql=&" union all"
sql=sql=&" Select TOP 2 * from _tiyu ""&orderby
sql=sql=&" union all "
sql=sql=&" Select TOP 2 * from _yule ""&orderby
sql=sql=&" union all "
sql=sql=&" Select TOP 2 * from _xiaohua ""&orderby
sql=sql=&" union all "
sql=sql=&" Select TOP 2 * from _jiaocheng ""&orderby
sql=sql=&") as t "
sql=sql=&" order by id desc "