This Lesson is for Members

Subscribe today and get access to all lessons! Plus direct HD download for offline use, enhances transcripts, member comment forums, and iTunes "podcast" RSS feed. Level up your skills now!

Unlock This Lesson

Already subscribed? Sign In

Autoplay

    See All Rows from Different Postgres Tables with Union All

    Brett CassetteBrett Cassette

    By default, union removes duplicate rows in the combined table. Union all, however, leaves all rows intact.

    postgresPostgreSQL
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:07 We can select the name from backers and do a union and select the name from a set of acquired backers from some other acquired dataset we got. We can order by the name, and now it's not apparent here, but union actually does a distinct on the data.

    00:30 If there are duplicates between two different tables, they'll be removed here. We can throw in the ID column just to see what those duplicates are.

    00:42 We can see that Brad Pitt is in both tables, Duane Johnson is in both tables, Shamu is in both tables, Pam Beasley.

    00:50 We can actually still look up just the names and keep them distinct with union all. If we're interested in getting only these values, but we're interested in getting duplicates of the values for some reason, maybe to prove that they're in both tables, or do run a count over them, then we can do that with union all.

    Discuss

    Discuss