You are on page 1of 2

Calvin Ayalla

Dr. Dollens
COM 340 HW8
10/24/2021

18.5 Write SQL queries for the books database (discussed in Section 18.3) that perform each
of the following tasks:
a. Select all authors from the Authors table with the columns
in the order lastName, firstName and authorID.

SELECT lastName, firstName, authorID

FROM authors

b. Select a specific author and list all books for that


author. Include the title, year and ISBN number. Order
the information alphabetically by title.

SELECT firstName, lastName, title, year, ISBN

FROM authors, authorISBN, titles

WHERE authorID = 3

ORDER BY title ASC

c. Add a new author to the Authors table.

INSERT INTO authors (authorID, lastName, firstName)

VALUES ( 7, 'Ayalla', 'Calvin' )

d. Add a new title for an author (remember that the book


must have an entry in the AuthorISBN table).

INSERT INTO AuthorISBN(AuthorID, ISBN) VALUES (3,


‘0234567888’);
INSERT INTO Titles (ISBN, Title, EditionNumber, Copyright)
VALUES (‘0234567888’, ‘Module 8’, 1, ‘2021’);

This study source was downloaded by 100000783702154 from CourseHero.com on 03-04-2024 18:21:47 GMT -06:00

https://www.coursehero.com/file/126554620/COM-340-HW8docx/
18.7 Correct each of the following SQL statements that refer to the books database.
a. SELECT firstName FROM author WHERE authorID = 3

SELECT FirstName FROM AUTHORS WHERE AuthorID = 3

b. SELECT isbn, title FROM Titles ORDER WITH title DESC

SELECT ISBN, Title FROM Titles ORDER BY Title DESC

c. INSERT INTO Authors (authorID,


firstName, lastName) VALUES ("2", "Jane",
"Doe")

INSERT INTO Authors (AuthorID, FirstName, LastName)


VALUES (2, ‘Jane’, ‘Doe’)

This study source was downloaded by 100000783702154 from CourseHero.com on 03-04-2024 18:21:47 GMT -06:00

https://www.coursehero.com/file/126554620/COM-340-HW8docx/

You might also like