Introduces the method and pitfalls of using UNION to join rows from two tables into the same columns
- [Instructor] Now we've learned how…to merge tables together using Join.…Joins allow us to merge columns from different tables,…it's like a horizontal kind of merge.…But we can also merge rows into the same columns…using a new keyword called Union.…It's a bit like a vertical merge.…So we return rows from more than one table,…but into the same number of columns.…Let's say that for audit reasons…we want to see the date when two tables were last updated.…We could run two queries, one after the other.…
SELECT date of last_update FROM actor,…and we see we have mostly the 15th…of February there with one exception.…And we could run the same thing for the address table,…which we see is mostly the 25th of September.…But we can join these two queries together like so.…And we literally write one SELECT query,…and a second one, and separate them with the word UNION.…
And if we click Go, we can see something straight away.…We've only been returned three rows.…By default UNION performs a select distinct,…that is to say it only gives us unique values.…
Join Emma Saunders as she shows you how to design and write simple SQL queries for data reporting and analysis. Review the different types of SQL, and then learn how to filter, group, and sort data, using built-in SQL functions to format or calculate results. Learn a bit about data types and database design. Discover how to perform more complex queries, such as joining data together from different database tables. Last but not least, Emma shows how to save your queries as views, so you can run them again and again.
- Using different versions of SQL
- Retrieving data with SELECT statements
- Filtering and sorting your results
- Transforming results with built-in SQL functions
- Grouping SQL results
- Merging data from multiple tables
- Identifying data types, and how to make sense of your database design
- Saving SQL queries
Skill Level Intermediate
1. Use SQL to Report Data
Data types in SQL databases5m 47s
2. Group your SQL Results
3. Merge Data from Multiple Tables
4. Advanced Features and Taking Your Learning Forwards
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.