Let's say I have 2 tables
People (id, name)
Dogs (id, name)
Can a view be created that contains all the dog names and all the people names so that for instance if I wanted to count how many entities are called Toby I'd have to query just the view?
Ideally it'd look something like
- John - where John came from the People table
- Toby - and Toby came from the dogs table
I'm using a PostgreSQL database but I'd be interested to know if any is able to do this.
CREATE VIEW w AS SELECT name FROM People UNION ALL SELECT name FROM dogs
could be used – Lukasz Szozda Nov 28 '20 at 16:13