关于"最新上传"的功能设计.
假设有A,B两个表,都有name和date字段,怎么可以可以取出最新的10条记录内容呢?也就是取出A,B两个表中的name字段.条件是A,B表中的date字段离现在最近.SQL语句怎么写啊?
------解决方案--------------------select top 10 [name] from(SELECT * from a union(select * from b) order by [date] desc)
------解决方案--------------------select top 10 [name],date from
(SELECT * from A
union ALL
select * from b) AB
order by date desc
------解决方案--------------------select top 10 name from (SELECT name,date from A union all select name,date from B) as newTable order by date DESC