I have three tables (users
, students
, and staff
). All three tables share three common attributes (emplid
, first_name
, and last_name
). I want to be able to do a union on students
and staff
like so:
SELECT emplid, first_name, last_name
FROM students
UNION
SELECT emplid, first_name, last_name
FROM staff
I then want to take that resulting query and insert any users into the users
table that are considered to be "new" (in the unioned results but not in the query table).
How would I accomplish this using SQL (specifically PostgreSQL)?
INSERT INTO users (...)?