Combining data

Pro lesson Beginner

Stacking batches

Combine files that arrive day by day with UNION, and keep their columns lined up.

10 min9 hands-on steps

In this lesson you will

  • Stack daily batches into one table with UNION ALL
  • Know when UNION removes rows, and when that is dangerous
  • Keep columns lined up when files disagree about their order

Words you'll meet

UNION ALL
Put the rows of one query underneath the rows of another, keeping every row.
UNION
The same, but rows that are exact copies in every column are kept only once.
By position
Columns are matched first with first, second with second. Their names are not checked.

The steps

Each step teaches one idea, then has you try it hands-on in your browser, and checks your work.

  1. 1One table per day
  2. 2UNION ALL
  3. 3Sent twice
  4. 4UNION
  5. 5Which one?
  6. 6Lined up by position
  7. 7Name your columns
  8. 8Tag each batch
  9. 9Challenge

This lesson is part of LearnDE Pro

$12 a month or $100 a year: every lesson, spaced-repetition flashcards, and Learn by teaching. Refund on request within 14 days.