Skip to content
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

done #17

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

done #17

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
30 changes: 30 additions & 0 deletions queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@
-- Your Query Goes Here
```

SELECT books.id, books.title, authors.name AS author_name
FROM books
INNER JOIN authors ON books.author_id = authors.id;

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


<br>

Expand All @@ -25,6 +33,9 @@
```sql
-- Your Query Goes Here
```
SELECT books.id, books.title, authors.name AS author_name
FROM authors
RIGHT JOIN books ON authors.id = books.author_id;

<br>

Expand All @@ -33,6 +44,9 @@
```sql
-- Your Query Goes Here
```
SELECT books.id AS book_id, books.title, authors.id AS author_id, authors.name AS author_name
FROM books
FULL JOIN authors ON books.author_id = authors.id;

<br>

Expand All @@ -43,6 +57,9 @@
```sql
-- Your Query Goes Here
```
SELECT books.title, publishers.name AS publisher_name, publishers.location
FROM books
INNER JOIN publishers ON books.publisher_id = publishers.id;

<br>

Expand All @@ -51,6 +68,9 @@
```sql
-- Your Query Goes Here
```
SELECT publishers.name AS publisher_name, books.title AS book_title
FROM publishers
LEFT JOIN books ON publishers.id = books.publisher_id;

<br>

Expand All @@ -59,6 +79,9 @@
```sql
-- Your Query Goes Here
```
SELECT books.title AS book_title, publishers.name AS publisher_name
FROM publishers
RIGHT JOIN books ON publishers.id = books.publisher_id;

<br>

Expand All @@ -67,5 +90,12 @@
```sql
-- Your Query Goes Here
```
SELECT
authors.id AS author_id, authors.name AS author_name,
books.id AS book_id, books.title AS book_title,
publishers.id AS publisher_id, publishers.name AS publisher_name
FROM authors
FULL JOIN books ON authors.id = books.author_id
FULL JOIN publishers ON books.publisher_id = publishers.id;

<br>