diff --git a/queries.md b/queries.md index b06f900..bb7d30d 100644 --- a/queries.md +++ b/queries.md @@ -6,16 +6,20 @@ 1. Using an **INNER JOIN**, list all books (left table) that have an assigned author (right table). The result should include only books with assigned authors. -```sql --- Your Query Goes Here -``` +SELECT name +FROM books +INNER JOIN authors +ON books.id = authors.id
2. Using a **LEFT JOIN**, list all authors (left table) and their corresponding books on the (right table). The result should include all authors, including those who don't have any books assigned. ```sql --- Your Query Goes Here +SELECT authors.name, books.title +FROM authors +INNER JOIN books +ON authors.id = books.author_id ```
@@ -23,7 +27,10 @@ 3. Using a **RIGHT JOIN**, list all books (right table) and their corresponding authors on the (left table). The result should include books without assigned authors. ```sql --- Your Query Goes Here +SELECT books.title, authors.name +FROM books +INNER JOIN authors +ON books.id = authors.id ```
@@ -31,7 +38,10 @@ 4. Using a **FULL JOIN**, list all records from the `books` and `authors` tables. The result should include all details from both tables, even if there are no match. ```sql --- Your Query Goes Here +SELECT books.title, authors.id +FROM books +FULL JOIN authors +ON books.author_id = authors.id ```
@@ -41,7 +51,10 @@ 1. Using an **INNER JOIN**, list all books (left table) and their corresponding publishers on the (right table). The result should include the book's title, publisher's name, and location. ```sql --- Your Query Goes Here +SELECT publishers.name, publishers.location +FROM publishers +INNER JOIN books +ON publishers.id = books.publisher_id ```
@@ -49,7 +62,10 @@ 2. Using a **LEFT JOIN**, list all publishers (left table) and any books they have published on the (right table). The result should include all publishers, including those who haven't published any books. ```sql --- Your Query Goes Here +SELECT publishers.name, books.title +FROM publishers +LEFT JOIN books +ON publishers.id = books.publisher_id ```