Skip to content

done #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

done #40

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,60 @@
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
books.title AS book_title,
authors.name AS author_name,
authors.nationality AS author_nationality,
books.publish_date
FROM books
INNER JOIN authors
ON books.author_id = authors.id
WHERE books.author_id IS NOT NULL;
```

<br>

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 AS author_name,
authors.nationality AS author_nationality,
books.title AS book_title,
books.publish_date
FROM authors
LEFT JOIN books
ON authors.id = books.author_id;
```

<br>

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
authors.name AS author_name,
authors.nationality AS author_nationality,
books.title AS book_title,
books.publish_date
FROM authors
RIGHT JOIN books
ON authors.id = books.author_id;
```

<br>

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
authors.name AS author_name,
authors.nationality AS author_nationality,
books.title AS book_title,
books.publish_date
FROM authors
FULL JOIN books
ON authors.id = books.author_id;
```

<br>
Expand All @@ -41,15 +70,27 @@
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
books.title AS book_title,
publishers.name AS publisher_name,
publishers.location AS publisher_location
FROM books
INNER JOIN publishers
ON books.publisher_id = publishers.id;
```

<br>

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 AS publisher_name,
publishers.location AS publisher_location,
books.title AS book_title
FROM publishers
LEFT JOIN books
ON publishers.id = books.publisher_id;
```

<br>
Expand Down