Reputation: 173
I have two table(tblnews and tblarticles). I want to show the latest articles and news together order by date. for example top 10 from these two tables and show the titles. but I don't know how should have these two selects I wrote the below code but it has some errors.
(select top (10)(([NewsId]) as id,([NewsTitle]) as title,([NewsDate]) as date,[NewsActive]) from [tblnews]
where ([NewsActive]='true')) Order by date Desc)
UNION ALL
(Select Top(10)([ArticleId] as id,[ArticleTitle] as title ,
[ArticleDate] as date, [ArticleActive])
From [tblarticle] where [ArticleActive]='true'
order by date DESC )order by date DESC
Upvotes: 1
Views: 1025
Reputation: 204874
What is with all the parentheses? Remove them
select * from
(
(select top (10) [NewsId] as id, [NewsTitle] as title, [NewsDate] as date, [NewsActive]
from [tblnews]
where [NewsActive]='true'
Order by date Desc)
UNION ALL
(Select Top(10) [ArticleId], [ArticleTitle], [ArticleDate], [ArticleActive]
From [tblarticle]
where [ArticleActive]='true'
order by date DESC )
) tmp
order by date DESC
Upvotes: 1