日期:2014-05-16 浏览次数:20955 次
select top 10 * from ( SELECT PostsId AS id, PostsTitle AS Title,PostsDate AS SendDate, 1 AS Type FROM BbsPosts WHERE (PostsUserId = 'admin' AND IsDeleted=False ) UNION ALL SELECT ReplyId AS id, ReplyTitle AS Title,ReplyDate as SendDate, 2 AS type FROM BbsReply WHERE (ReplyUserId = 'admin' AND IsDeleted=False ) ) order by SendDate desc
------解决方案--------------------
如果是按 SendDate 排序
select top 10 * from (
SELECT PostsId AS id, PostsTitle AS Title,PostsDate AS SendDate, 1 AS Type
FROM BbsPosts
WHERE (PostsUserId = 'admin' AND IsDeleted=False )
UNION ALL
SELECT ReplyId AS id, ReplyTitle AS Title,ReplyDate as SendDate, 2 AS type
FROM BbsReply
WHERE (ReplyUserId = 'admin' AND IsDeleted=False ) )
order by SendDate desc