Solved

union all between three table

Posted on 2013-01-10
2
421 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

732 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