Academic Tutorials



English | French | Portugese | German | Italian
Home Advertise Payments Recommended Websites Interview Questions FAQs
News Source Codes E-Books Downloads Jobs Web Hosting
Chats

SQL Tutorial
SQL Introduction
SQL Select Statement
SQL WHERE Clause
SQL Insert Statement
SQL Update Statement
SQL Delete Statement
SQL Order By Clause
SQL AND OR Operator
SQL in operator
SQL Between
SQL Aliases
SQL Join
SQL Outer Join
SQL Union
SQL Subqueries
SQL Date Function
SQL Create Statement
SQL Drop Statement
SQL Alter
SQL Function
SQL Group By Statement
SQL Select Into
SQL Create View
SQL Server
SQL Summary

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting
Network Sites


SQL Union


Previoushome Next





SQL Union


SQL UNION combine the results of two queries together.
A D V E R T I S E M E N T
In this respect, UNION is similar to JOIN in that they are both used to related information from multiple tables. One restriction of UNION is that all corresponding columns need to be of the same data type and UNION only select distinct values.


Syntax:


[SQL Statement 1]
UNION
[SQL Statement 2]

Table Store_Information

Store_name Sales Date
Los Angeles $1500 Jan-05-2005
San Diego $250 Jan-07-2005
Los Angeles $300 Jan-08-2005
Boston $700 Jan-08-2005

Table Internet_Sales

Date Sales
Jan-07-2005 $250
Jan-10-2005 $535
Jan-11-2005 $320
Jan-12-2005 $750

If we want to find out all the dates where there is a sales transaction.We use the following SQL statement:


SELECT Date FROM Store_Information
UNION
SELECT Date FROM Internet_Sales


Output:

Date
Jan-05-2005
Jan-07-2005
Jan-08-2005
Jan-10-2005
Jan-11-2005
Jan-12-2005


SQL UNION ALL

The SQL UNION ALL command is also to combine the results of two queries together. The difference between UNION ALL and UNION is that, UNION ALL selects all values while UNION only selects distinct values.


Syntax :

SELECT Date FROM Store_Information
UNION ALL
SELECT Date FROM Internet_Sales


Output :

Date
Jan-05-2005
Jan-07-2005
Jan-08-2005
Jan-08-2005
Jan-07-2005
Jan-10-2005
Jan-11-2005
Jan-12-2005