sql-join Flashcards
What is a foreign key?
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 do you join two SQL tables?
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 do you temporarily rename columns or tables in a SQL statement?
We can alias them using the “as” keyword.
select “products”.”name” as “product”,
“suppliers”.”name” as “supplier”
from “products”
join “suppliers” using (“supplierId”);