sql-join Flashcards

1
Q

What is a foreign key?

A

It allows for the storage of information related to one table to be stored in another table rather than have all of that information in one table.

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

How do you join two SQL tables?

A

Using the keyword

select *
from “products”
join “suppliers” using (“supplierId”);

We are selecting all columns from both the “products” table and the “suppliers” table.

The join clause follows the from clause.

The join clause is instructing the database server to link the two tables by their “supplierId” column.

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

How do you temporarily rename columns or tables in a SQL statement?

A

We can alias them using the “as” keyword.

select “products”.”name” as “product”,
“suppliers”.”name” as “supplier”
from “products”
join “suppliers” using (“supplierId”);

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