SQLTeam.com | Weblogs | Forums

How to select tow select statements in to single results


#1

Hi ALL,
i have a 2 select results ..finaly i select singel statement like below example

1‌ select statement

s‌elect 'topStories‌‌‌' as First

2‌ select statemnet results

Present_Position prese_url Previous_Position previ_url
1 https://www.thestar.com.my/tech/tech-news/2018/10/29/race-to-reinvent/ 1 https://www.ft.com/content/51c2c41a-d8fe-11e8-a854-33d6f82e62f8
2 https://www.telegraph.co.uk/politics/2018/10/28/no-wonder-dysons-singapore-britain-currently-doomed-humiliation/ 2 https://www.telegraph.co.uk/politics/2018/10/28/no-wonder-dysons-singapore-britain-currently-doomed-humiliation/
3 https://gas2.org/2018/10/27/dyson-electric-car-to-be-built-in-singapore/ 3 https://www.thestar.com.my/tech/tech-news/2018/10/29/race-to-reinvent/‌‌

F‌inaly i want display the results like

First
-‌----------------------------------------------------------------
‌‌‌‌ 'topStories‌‌‌'
-‌-------------------------------------------------------------------------------------------
1 https://www.thestar.com.my/tech/tech-news/2018/10/29/race-to-reinvent/ 1 https://www.ft.com/content/51c2c41a-d8fe-11e8-a854-33d6f82e62f8
2 https://www.telegraph.co.uk/politics/2018/10/28/no-wonder-dysons-singapore-britain-currently-doomed-humiliation/ 2 https://www.telegraph.co.uk/politics/2018/10/28/no-wonder-dysons-singapore-britain-currently-doomed-humiliation/
3 https://gas2.org/2018/10/27/dyson-electric-car-to-be-built-in-singapore/ 3 https://www.thestar.com.my/tech/tech-news/2018/10/29/race-to-reinvent/‌

P‌lease help me

T‌wo querys like

‌‌‌
s‌elect '‌‌topStories‌‌‌'

A‌ND

select
a.position as Present_Position,
prese_url,
b.position as Previous_Position,
previ_url
from
(select position,type,url as prese_url from @xmldata1 where type='topStories'
) A full outer join
(select position,type,url as previ_url from @xmldata6 where type='topStories'
) B ON a.type=B.type
and a.position=b.position‌‌

‌‌‌
‌‌‌


#2

use Union for example:-

  Select column1,column2,column3  from Table
Union all
  Select column1,column2,column3  from Table

Make sure you have the same number of columns in both queries