Solved

union all between three table

Posted on 2013-01-10
2
414 Views
Last Modified: 2013-01-10
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d630590]
  where sent = 0


SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d732590]
  where sent = 0


SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d84444]
  where sent = 0


i want to union the three table and order by datein and timein
0
Comment
Question by:afifosh
2 Comments
 
LVL 21

Assisted Solution

by:Dale Burrell
Dale Burrell earned 250 total points
ID: 38765256
Add " union all " between each query and add " order by datein, timein" after the last query.
0
 
LVL 25

Accepted Solution

by:
jogos earned 250 total points
ID: 38765266
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d630590]
  where sent = 0

union all
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d732590]
  where sent = 0

union all
SELECT [ID]
      ,[ReqPort]
      ,[Message]
      ,[MSISDN]
      ,[Datein]
      ,[Timein]
FROM [CGI_SMS_SERVICES].[dbo].[CGI_SMS_d84444]
  where sent = 0
order by datein ,timein

Open in new window

0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now