sql union and union all

 UNION and UNION ALL operators in SQL Server, are used to combine the result-set of two or more   SELECT queries. Please consider India and UK customer tables below


create table tblindiacustomers(

id int primary key identity(1,1),

name varchar(29),

email varchar(30)

);


create table tblUSAcustomers(

id int primary key identity(1,1),

name varchar(29),

email varchar(30)

);


insert into tblindiacustomers values

('Ram','ram@g.com'),

('Ravi','ravi@g.com'),

('Divya','divya@g.com');


insert into tblUSAcustomers values

('John','john@g.com'),

('Ravi','ravi@g.com'),

('michale','michale@g.com');

select id,name,email from tblindiacustomers
union all
select id,name,email from tblusacustomers;

select id,name,email from tblindiacustomers
union
select id,name,email from tblusacustomers;

Comments

Popular posts from this blog

Automatically send Birthday email using C#.Net

Drag and Drop multiple File upload using jQuery AJAX in ASP.Net using C# and VB.Net

Difference between each and map in jquery