(a) How many rows will be returned by the following command? [Select] SELECT DISTINCT a.name FROM adult a LEFT JOIN parent_child pc ON a.id = pc.parent LEFT JOIN child c ON pc.child = c.id; (b) How many rows will be returned by the following command? [Select] SELECT DISTINCT a.name FROM adult a RIGHT JOIN parent_child pc ON a.id = pc.parent RIGHT JOIN child c ON pc.child = c.id; <
SQL
SQL stands for Structured Query Language, is a form of communication that uses queries structured in a specific format to store, manage & retrieve data from a relational database.
Queries
A query is a type of computer programming language that is used to retrieve data from a database. Databases are useful in a variety of ways. They enable the retrieval of records or parts of records, as well as the performance of various calculations prior to displaying the results. A search query is one type of query that many people perform several times per day. A search query is executed every time you use a search engine to find something. When you press the Enter key, the keywords are sent to the search engine, where they are processed by an algorithm that retrieves related results from the search index. Your query's results are displayed on a search engine results page, or SER.
![Refer to the sample tables and sample data below.
Tables:
adult (id(pk), name)
child (id(pk), name)
parent_child (parent (pk, fk), child (pk, fk))
foreign key (parent) references adult(id)
- foreign key (child) references child(id)
mysql> SELECT * FROM adult;
|id|name
|
1 | Homer Simpson.
| 2 | Marge Simpson
|
|
|
|
|
|
3 | Fred Flintstone
4 | Wilma Flintstone
5 | George Jetson
6 | Jane Jetson
7 | Patty Bouvier
8 | Selma Bouvier
mysql> SELECT * FROM child;
|id|name
| 11 | Bart
| 12 | Lisa
| 13 | Maggie
| 14 |
Pebbles
| 15 | Judy
| 16 | Elroy
| 17 | Ling
mysql> SELECT * FROM parent_child;
| parent child |
1 |
2 |
1 |
2
1 |
21
3 |
4
5 |
in 10 in
6
5 |
1000
11
11
12
12
13 |
13
14
14 |
8
15
5566
15 |
6 | 16
17
16 |](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffd5c5bed-428f-4fc6-88a2-4182bb244de6%2F31360c29-9e85-41a6-bead-599813e17ac9%2Faaearbf_processed.png&w=3840&q=75)
![(a) How many rows will be returned by the following command? [Select]
SELECT DISTINCT a.name FROM adult a
LEFT JOIN parent_child pc ON a.id = pc.parent
LEFT JOIN child c ON pc.child = c.id;
(b) How many rows will be returned by the following command? [Select]
SELECT DISTINCT a.name FROM adult a
RIGHT JOIN parent_child pc ON a.id = pc.parent
RIGHT JOIN child c ON pc.child = c.id;](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffd5c5bed-428f-4fc6-88a2-4182bb244de6%2F31360c29-9e85-41a6-bead-599813e17ac9%2F2489v7_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)