sql-join Flashcards

1
Q

What is a foreign key?

A

The primary key from another table. A shared data value between tables.

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

Select cols
from table
join table using (foreign key)

select *
from “products”
join “suppliers”
on “suppliers”.”id” = “products”.”supplierId”;

if the id names are not identical then you must use a join on to link different id names

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

Use the keyword “as” and place it after the table names and provide an alias. Ex: from “table” as “t”. Do the same with columns after the select keyword.

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