How to SELECT rows from multiple tables JOINing on specific key?
I have several tables states(year)
with same structure. I want to make a VIEW selecting only rows from states(year)
with propertyid contained in table properties
under specific user:
CREATE OR REPLACE VIEW selected_states AS
SELECT *, 2017 AS year FROM states2017
UNION ALL SELECT *, 2018 AS year FROM states2018
AS s
JOIN properties p ON s.propertyID = p.propertyID WHERE p.userID=1
getting an error
The used SELECT statements have a different number of columns
SQLfiddle: http://sqlfiddle.com/#!9/aca397c