Lets say I have a table called Players and another table called Coaches.
Each table has columns FirstName, LastName, UserID, Address.
There is currently a view called PeopleView which is a simple select statement.
select FirstName, LastName, UserID from Players;
I now want PeopleView to also return the same data from the Coaches table.
select FirstName, LastName, UserID from Coaches;
So now when this view is executed it will show all players and coaches in the database even though you will not know which record is a coach or player.
Thanks and I am hoping this is easy for sql experts.
CodePudding user response:
But, you can know who is who by adding yet another column:
select 'Player' what, FirstName, LastName, UserID from Players
union all
select 'Coach' what, FirstName, LastName, UserID from Coaches