blog post

UNION combines the result sets of two queries.
Column data types in the two queries must match.
UNION combines by column position rather than column name.
img union

The SQL UNION syntax

The general syntax is:
SELECT column-names
  FROM table-name
SELECT column-names
  FROM table-name

SQL UNION Examples

Problem: List all contacts, i.e., suppliers and customers.
SELECT 'Customer' As Type, 
       FirstName + ' ' + LastName AS ContactName, 
       City, Country, Phone
  FROM Customer
SELECT 'Supplier', 
       ContactName, City, Country, Phone
  FROM Supplier

This is a simple example in which the table alias would be useful

  • Share This Story

Pleas give your valuable comments to improve the contents.

about author

Atul kumar shukla

I'm Atul Kumar Shukla, working as a web developer.
Welcome to my Blog. This is my personal blog where i post my own questions and answers , articles about ASP.Net., SQL Server, HTML, CSS, Jquery and many more..

Visit Profile

Leave a comment


Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email


Style Switcher

Change Color

×! We use cookies to improve your user experience. More information