课程: SQL Hands-On Practice: Solve Business Problems

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Combining multiple data sources with UNION

Combining multiple data sources with UNION

- [Instructor] To solve this problem, we're going to use UNION. Similar to JOIN, UNION combines data sets together. However, unlike JOINs, UNION combines data sets vertically by stacking multiple select statements, kind of like making a sandwich. UNION also ensures that all duplicate rows are removed and excluded from the output. If you want to keep the duplicates, you can use UNION ALL instead. There are a few rules of UNION that we'll go over in the next video. But let's solve this problem really quick as an example, to see how it works. We're going to combine three different data sources into one output. We have website leads, prospects, and users. And we have to combine all of these into one output. We're first going to start with select, name, email, FROM, the websiteleads table. And let's run this to see what it looks like. Here, we have a list of all of the names and emails from the websiteleads table.…

内容