UNION
45.3
Exercise

UNION - 2

Write a query to display the following under a single column:

  1. Names of all students enrolled in the Java course
  2. Names of all the books that belong to the Java course
  3. Names of all authors who have written at least one book that belongs to Java


Also, show the kind of data, by displaying Student, Book or Author as type in front of each result. The headers for type and the student/book/author data should be type and javaData respectively.

The result should look something like this:

type javaData
Student Joaquin
Book Basics of Java
Student Heath
Author Mat Reeves
Book Advanced Java

Hint:

If we want to select type as Book, and name of book from books, we can use the following query:

SELECT  'Book' AS type,
        name
FROM    books