FictionBooks and NonFictionBooks with columns BookID, Title, and Author.Title and Author columns from both tables.Jump into concepts and practice - no test required
FictionBooks and NonFictionBooks with columns BookID, Title, and Author.Title and Author columns from both tables.FictionBooks table and insert dataFictionBooks with columns BookID (integer), Title (text), and Author (text). Insert these rows exactly: (1, 'The Great Gatsby', 'F. Scott Fitzgerald'), (2, '1984', 'George Orwell'), (3, 'To Kill a Mockingbird', 'Harper Lee').Use CREATE TABLE to define the table and INSERT INTO to add rows.
NonFictionBooks table and insert dataNonFictionBooks with columns BookID (integer), Title (text), and Author (text). Insert these rows exactly: (1, 'Sapiens', 'Yuval Noah Harari'), (2, 'Educated', 'Tara Westover'), (3, '1984', 'George Orwell').Repeat the table creation and insertion steps for the NonFictionBooks table.
Title and Author from both tablesTitle and Author columns from FictionBooks and NonFictionBooks and combines them using a set operation that removes duplicates.Use the UNION operator to combine the two SELECT statements and remove duplicates.
ORDER BY clause to the query to sort the results by Title in ascending order.Use ORDER BY Title ASC at the end of the query to sort the results by title.
Which rule must be followed when using SQL set operations like UNION or INTERSECT?
Which of the following SQL queries correctly uses UNION with matching columns?
-- Table A: (id INT, name VARCHAR)
-- Table B: (user_id INT, username VARCHAR)
A)SELECT id, name FROM A UNION SELECT user_id, username FROM B;
B)SELECT id FROM A UNION SELECT user_id, username FROM B;
C)SELECT id, name FROM A UNION SELECT user_id FROM B;
D)SELECT id, name FROM A UNION SELECT user_id, username, email FROM B;
Given the tables and query below, what will be the output?
Table X:
id | value
1 | 'A'
2 | 'B'
Table Y:
code | val
2 | 'B'
3 | 'C'
Query:SELECT id, value FROM X
UNION
SELECT code, val FROM Y;
Identify the error in the following SQL set operation:
SELECT id, name FROM Customers
UNION
SELECT customer_id FROM Orders;You have two tables:
Employees(emp_id INT, emp_name VARCHAR, dept VARCHAR)
Managers(manager_id INT, manager_name VARCHAR)
You want to combine employee and manager names into one list using a set operation. Which query correctly applies set operation column matching rules?
A)SELECT emp_id, emp_name FROM Employees UNION SELECT manager_id, manager_name FROM Managers;
B)SELECT emp_name FROM Employees UNION SELECT manager_name FROM Managers;
C)SELECT emp_name, dept FROM Employees UNION SELECT manager_name, manager_id FROM Managers;
D)SELECT emp_id, emp_name, dept FROM Employees UNION SELECT manager_id, manager_name FROM Managers;