sql-join Flashcards
What is a foreign key?
Notice how each row in the “products” table has a “supplierId” column. That column specifically refers to values in the “supplierId” column of the “suppliers” table. This is known as a foreign key. Instead of putting all of the supplier information for a product into the product row itself, there is instead just one column that links the “products” table to the “suppliers” table.
How do you join two SQL tables?
select *
from “products”
join “suppliers” using (“supplierId”);
How do you temporarily rename columns or tables in a SQL statement?
select “products”.”name” as “product”,
“suppliers”.”name” as “supplier”
from “products”
join “suppliers” using (“supplierId”);