sql-join Flashcards
1
Q
What is a foreign key?
A
The primary key from another table. A shared data value between tables.
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
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.