MySQL Forums
Forum List  »  General

SQL UNION task help request
Posted by: Dariusz Jot
Date: December 27, 2023 03:31AM

Could You help me wit h this task, please?

You are working with the library books database.

The Books table has the columns id, name, year.

The library has new books whose information is stored in another table called "New", however they do not have a year column.

Write a query to select the books from both tables, Books and New, combining their data. For the year column of the New books use the value 2022.

Also, select only the books that are released after the year 1900.

The result set should contain the name and year columns only, ordered by the name column alphabetically.

My solution:

My solution:

SELECT name, year AS str('2022')

FROM New

UNION

SELECT name, year

FROM Books

WHERE year > 1900

ORDER BY name ASC

Options: ReplyQuote


Subject
Written By
Posted
SQL UNION task help request
December 27, 2023 03:31AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.