20 May 2016 Sudhanshu Ranjan 1.35k
What is the difference between UNION and UNION ALL?
UNION and UNION ALL both are merged the data of two different tables in single table. UNION display only the unique data in both table whereas UNION ALL display duplicate data also. Column name should be match on both table.
UNION ALL is typically faster than UNION.
CREATE TABLE [dbo].[employee]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [varchar](50) NULL, CONSTRAINT [PK_employee] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]
CREATE TABLE [dbo].[salary]( [id] [int] NULL, [salary] [int] NULL ) ON [PRIMARY]
select ID from employee UNION select id from salary
select ID from employee UNION ALL select ID from salary
Sudhanshu Kumar Ranjan | Lead Engineer at HCL Technologies | Expertise in Microsoft Technology | Author | Blogger | Programmer
Connect with him on Facebook | Google+ | LinkedIn | Twitter
- What is Interface in C#? Explain
- What is static Constructor? Explain.
- What is Prime Number? Print Prime Number using C#
- the webpage cannot be found http 404 error. Fixed!
- How to install asp.net mvc 5 in visual studio 2012
- What is Angular 2 and how it is different from Angularjs 1
- What is the difference between ViewData, ViewBag and TempData?
- Microsft online test question for Dotnet -1
- What is AngularJs?
- Get manager name in employee table mostly asked in interview question
Leave a comment
Search In This Website
- TypeError: $(...).autocomplete is not a function
- Paging in MVC using C# with razor
- How to use CKEditor in MVC application/ Asp.net application.
- Bind dropdown in MVC using jquery with C#
- How to implement CAPTCHA in MVC 4 using C# Asp.net.
- set default page while using “Area” in MVC application
- Create and consume a simple WCF Restful service using AngularJs application
- datepicker textbox in mvc 4 using JQuery
- Bind the dropdown using angularjs in mvc application
- Bind gridview and paging example in angularjs
- Sql Server(9)
- Entity Framework(3)
- Angular Js(7)
- Web API(0)
- Web Service(1)
- Crystal Report(0)
- My SQL(5)
- Visual Studio(18)
- Knockout JS(0)
- Microsoft Office(0)
- Node JS(0)