Welcome to PC Teach Me...

Free Computer Training Videos.

Although you do not need to register to access this site. Registering has its benefits. Such as:

  • Access to training material associated with the video you are watching [if applicable]
  • Automatic email updates when new training videos are available.
  • Ask for a training video.
  • Exclusive access to pose questions to me [limited availability as I am doing this for free :-)].
  • Free contribution of your own training topics, this includes referencing your videos outside of PC Teach Me.
  • Its Free!

Member Login

Lost your password?

Not a member yet? Sign Up!

By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime.

25425 Registered Users
71 Number Of Articles
Free Video Tutorials (Email) Free Video Tutorials (RSS) Free Video Tutorials (Twitter) Free Video Tutorials (Flickr)

SQL: Union Statement

sql SQL: Union Statement SQL: Merging Tables (union)

When it comes to data manipulation there is only so much you can do. Most of the options on data manipulation stem from three distinct types:

  1. Field Manipulation.
    These are options such as case statements, IF statements or a form of calculation.
  2. Joins
    The ability to cross reference different tables together, for more information on this please refer to the  Joins tutorial.
  3. Merging Data
    The ability to put two or more separate data sources together to create a new dataset (the purpose of this video).

What are SQL Unions?

Unions allow you to “a but” two separate data sources and place them in one SQL data source. This is not for the likes of joining customers and orders but rather the ability to have customers and employees in the same data source.

A good example of this is if you want a definitive address list, both the customers table and the employees table house disparate data but in the confines of an address list they are in most respects the same. So by using the union statement you can merge the two isolated tables together to create one address list.

But be aware! there are two types of Union to choose from.  A lot of newbies pick up the “Union” statement and not discover nuances between the “Union” and “Union All”.  This video will allow you to fully understand the differences.

To fully understand this you must first understand:

  1. The Select Statement.
  2. The Where Clause.

Other SQL Videos

This video is one of many SQL tutorials on this site click here for more

Related Posts

115 Comments

  1. Kimmygr33 says
    27 May 12 at 7:40pm

    Yes, you can union more than two tables, but you have to have the same number of columns and same datatype. Here’s an example of a three table union:
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee1
    UNION ALL
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee2
    UNION ALL
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee3
    ORDER BY Lastname;

  2. Kimmygr33 says
    27 May 12 at 7:40pm

    [..YouTube..] Yes, you can union more than two tables, but you have to have the same number of columns and same datatype. Here’s an example of a three table union:
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee1
    UNION ALL
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee2
    UNION ALL
    SELECT Lastname, Firstname, Address, Zipcode
    FROM Committee3
    ORDER BY Lastname;

  3. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  4. grldescms says
    12 Jul 11 at 5:45am

    [..YouTube..] ahhh okey okey no prob!! ^___^

  5. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  6. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  7. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  8. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  9. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  10. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^

  11. grldescms says
    12 Jul 11 at 5:45am

    ahhh okey okey no prob!! ^___^ 

  12. grldescms says
    12 Jul 11 at 4:45am

    ahhh okey okey no prob!! ^___^

  13. PCTeachME says
    11 Jul 11 at 10:20am

    Hi, Appologies for the sound. My regular microphone was not working that day to the sound is very muffled and full of bass (which is not the norm). Still, I do hope the video helped you out.

  14. PCTeachME says
    11 Jul 11 at 10:20am

    [..YouTube..] Hi, Appologies for the sound. My regular microphone was not working that day to the sound is very muffled and full of bass (which is not the norm). Still, I do hope the video helped you out.

  15. PCTeachME says
    11 Jul 11 at 10:20am

    [..YouTube..] @grldescms Hi, Appologies for the sound. My regular microphone was not working that day to the sound is very muffled and full of bass (which is not the norm). Still, I do hope the video helped you out.

Leave a Comment

You must be logged in to post a comment.

Valid XHTML 1.0 Transitional website security