Adv Database Management: SQL Unions

Please note that the following blog post provides a summary view for what you need to get done (left column) and quick examples that illustrate how to do it in SQL (right column with SQL code in red). For more information please see the resources below:

Union
SELECT ename, job, deptno
  FROM emp
  UNION
SELECT name, title, deptid
  FROM emp_history
Intersect
SELECT ename, job, emptno
  FROM emp
  INTERSECT
SELECT name, emptid, title
  FROM emp_history
Union all (will include duplicate values)
SELECT ename, job, emptno
  FROM emp
  UNION ALL
SELECT name, emptid, title
  FROM emp_history

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: