IT Community - Software Programming, Web Development and Technical Support

Union and Union All

This is a discussion on Union and Union All within the Database Support forums, part of the Web Development category; Hi all... Can we discuss briefly about the Union and Union All in sql. Thanks in advance......


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-25-2008, 04:53 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default Union and Union All

Hi all...



Can we discuss briefly about the Union and Union All in sql.



Thanks in advance...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-25-2008, 04:58 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Union and Union All

Hi all...


Union :
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type.

Syntax:
select * from table1_name
union
select * from table2_name


Union All:
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

Syntax:
select * from table1_name
union all
select * from table2_name

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-03-2008, 01:41 AM
priyan priyan is offline
D-Web Sr.Programmer
 
Join Date: Mar 2007
Posts: 133
priyan is on a distinguished road
Default Re: Union and Union All

Hi vinoth,

Could you please suggest me which one is good method in the following condition.

Assume that this table contains more than 1 lakh records.

1. Using UNION (same table)
select * from employee where age=25
union
select * from employee where age=26

2. Using OR (same table)
select * from employee where age=25 or age=26
__________________
Keep smiling...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make out of Structure and Union velhari C and C++ Programming 2 04-03-2008 03:55 AM
UNION ALL faster than a UNION? vadivelanvaidyanathan Database Support 4 08-18-2007 02:04 AM
What is the difference between UNION and UNIONALL in SQL Server? bluesky Database Support 1 07-25-2007 05:53 AM
what is the UNION in c++? with Example sundarraja C and C++ Programming 1 07-20-2007 07:44 AM
What's the difference between a structure and a union prasath C and C++ Programming 1 07-18-2007 05:14 AM


All times are GMT -7. The time now is 04:54 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0