How to Work With Union in SQL

In this article I am going to explain about how to work with union in SQL.
  • 2167

Introduction

Here I am going to explain how to retrieve data from more than than one table. Join operator is used to fetch data from two or more than two table.  There is an other way to retrieve data from more than one table into result set known as union. Here we use union to fetch data from two different tables in result set table.

Each result set in union must return same number of columns and corresponding columns in result set must have same data type. Union combine data from two or more result set into one result set.

A Statement that create mcninvoices table

inv.jpg

Statements that insert data in mcninvoices table

inv (2).jpg

A Statement that is used to fetch data from mcninvoices table

inv111.jpg

A Statement that using Union

Clipboard14.jpg


© 2019 DotNetHeaven. All rights reserved.