SQL Flashcards

1
Q

In the LEFT JOIN below which table returns all row?

Which table fills matching rows and returns null for non-matching rows?

SELECT *
FROM newspaper
LEFT JOIN online
ON newspaper.id = online.id;

A

The newspaper table returns ALL rows.

The online table FILLS matching rows and returns NULL for non-matching rows.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a primary key calls that appears in another table?

A

Foreign Key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the primary and foreign key in this example, and are they the same value?

SELECT *
FROM classes
JOIN students
ON classes.id = students.class_id;

A

Yes, they are the same value.

Primary key is classes.id
Foreign key is students.class_id

How well did you know this?
1
Not at all
2
3
4
5
Perfectly