beginnerSet Operators — UNION, INTERSECT, EXCEPT/MINUS

What requirement must both queries satisfy before you can combine them with a set operator?

Both queries must return the same number of columns, in a compatible order and type — SQL matches columns positionally, not by name. The final result's column names come from the first query alone; the second query's aliases are ignored entirely.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.

What requirement must both queries satisfy before you can combine them with a set operator?

Next Step

Continue to Why can a stored procedure COMMIT but a function cannot?← Back to all SQL questions