sql-join Flashcards

1
Q

What is a foreign key?

A

A FOREIGN KEY is a key used to link two tables together.

A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in another 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

join clause “table name” using (“commoncolumn”)

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 their names as follows:
select "p"."name" as "product",
       "p"."category",
       "s"."name" as "supplier",
       "s"."state"
  from "products" as "p"
  join "suppliers" as "s" using ("supplierId");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly