---
title: "SQL UNION Operator"  
description: "SQL UNION Operator"  
author: "Anonymous User"  
published: 2015-11-03  
updated: 2015-11-03  
canonical: https://www.mindstick.com/forum/33565/sql-union-operator  
category: ".net"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# SQL UNION Operator

what is use of [union and union](https://www.mindstick.com/interview/23347/when-will-union-and-union-all-behave-the-same) all [Operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) in sqlserver.

## Replies

### Reply by Anonymous User

The UNION operator is used to combine the result-set of two or more SELECT statements.

Notice that each SELECT statement within the UNION must have the same number of columns. The columns must also have similar data types. Also, the columns in each SELECT statement must be in the same order.

## SQL UNION Syntax

SELECT column_name(s) FROM table1\
UNION\
SELECT column_name(s) FROM table2;

**Note:** The UNION operator selects only distinct values by default.

**SQL [UNION ALL](https://www.mindstick.com/blog/11268/union-and-union-all-operator-in-sql) Syntax**

SELECT column_name(s) FROM table1\
UNION ALL\
SELECT column_name(s) FROM table2;

**Note** **:** The UNION operator selects All (duplicate values also) values by default.

For Exp:

**Union**

```
SELECT City FROM Customer
UNION

SELECT City FROM Supplier

ORDER BY City
```

**Result :**

```
    Result: 
```

**Union All**

```
SELECT City FROM Customer
UNION
SELECT City FROM Supplier
ORDER BY City
```


---

Original Source: https://www.mindstick.com/forum/33565/sql-union-operator

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
