Monday, 27 November 2017

Learn Sql server in hindi/urdu part-14(Union and Union All)







--The UNION operator is used to combine the result-set of two or more SELECT statements.



--Each SELECT statement within UNION must have the same number of columns

--The columns must also have similar data types

--The columns in each SELECT statement must also be in the same order





create table tblIndiaCustomers

(

id int identity,

Name nvarchar(20),

email nvarchar(20)

)

create table tblUKCustomers

(

id int identity,

Name nvarchar(20),

email nvarchar(20)

)





insert into tblIndiaCustomers

values('Aditi','Aditi@yahoo.com')



insert into tblIndiaCustomers

values('Rahul','Rahul@yahoo.com')



insert into tblIndiaCustomers

values('Sundar','Sundar@yahoo.com')



insert into tblIndiaCustomers

values('Ganesh','Ganesh@yahoo.com')





----------------------------------------



insert into tblUKCustomers

values('Mark','Mark@hotmail.com')



insert into tblUKCustomers

values('Ben','Ben@hotmail.com')



insert into tblUKCustomers

values('Linda','Linda@hotmail.com')



insert into tblUKCustomers

values('Suzan','Suzan@hotmail.com')



----------------------------------





select * from tblIndiaCustomers

union

select * from tblUKCustomers





select * from tblIndiaCustomers

union all

select * from tblUKCustomers










No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...