1
Answer

Using two different tables in query

In my ASP.NET application, I am wishing to select top 20 records (10 and 10) from two different tables named 'PostedByAdmins' and 'PostedByGuest'. I have used following queries but no use:-


SELECT TOP 20 [title], [source], [description] FROM [PostedByAdminsPostedByGuest] ORDER BY [id] DESC

SELECT TOP 20 [title], [source], [description] FROM [PostedByAdmins], [PostedByGuest] ORDER BY [id] DESC


Even I tried to delete TOP 20 even I don't wish this but no use like

SELECT [title], [source], [description] FROM [PostedByAdmins], [PostedByGuest] ORDER BY [id] DESC

I tried to delete TOP 20 and ORDER by but no use as

SELECT [title], [source], [description] FROM [PostedByAdmins], [PostedByGuest]

For the demonstration purpose I check both table one by one and this worked fine


SELECT TOP 20 [title], [source], [description] FROM [PostedByAdmins] ORDER BY [id] DESC

SELECT TOP 20 [title], [source], [description] FROM [PostedByGuest] ORDER BY [id] DESC


So, there is no problem with development of tables or say in other coding except query. 
So, guys what query I use to fix my issue. Remeber I need top 10 records from both tables. 


Thanks in advance.

Answers (1)