Database HELP Consider the following two views below. One database view contains
ID: 3751877 • Letter: D
Question
Database HELP
Consider the following two views below. One database view contains records of Non Playable Characters in a role playing game. The second view contains records for playable characters for the same game. Remember views are like tables and you can treat them like tables when reading from them. If we wanted to list all characters from both views into one new view which you will find an example in the All Characters view below, what SET operation could we perform to achieve the desired result?
NonPlayableCharacters CharID 334 344 346 Level CharName Goblin Griffin Dragon 13 29 PlayableCharacters CharID 44391 44392 44393 CharName lamRoot99 NedStark347 PhillipFryl Level 21 10 12 Desired Result AllCharacters CharID 334 344 346 44391 44392 44393 Level CharName Goblin Griffin Dragon lamRoot99 NedStark347 PhillipFryl 13 29 21 10 12Explanation / Answer
Answer:
The Union set operation is used to combine the two views which are having same type of columns.
Syntax:
Create View [Name] as
select columns from Table1
Union
select Columns from Table2
Below query is used to create the view which will display all playable characters.
Create view AllCharacters as
select * from NonPlayableCharacters
Union
select * from Playablecharacters. /*This will list down all the playable characters*/
Expected Output:
CharID CharName Level 334 Goblin 5 344 Griffin 13 346 Dragon 29 44391 IamRoot99 21 44392 NedStark347 10 44393 PhilipFry1 12Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.