MySQL_DAY_3
MySQL_DAY_3
tables
• Can create
relationship
VENN
DIAGRAM
Explicit Joins:
Use dedicated keywords like JOIN and the ON clause
to clearly define the joining tables and the matching
conditions between them.
TYPES OF Implicit Joins:
JOINS Don't use explicit join keywords; they rely on the
order of tables mentioned in the FROM clause and
matching column names to infer the join type
Inner Join (Default): Keeps only rows with matching
values in both tables.
Left Join: Keeps all rows from the left table, even if no
match exists in the right table. Null values fill in for
TYPES OF unmatched right columns.
Right Join: Keeps all rows from the right table, filling in
JOINS nulls for unmatched left columns.
Full Outer Join: Includes all rows from both tables,
regardless of matches.
Inner Join :
Retrieves records with matching values in both tables.
Syntax :
SELECT columns
RIGHT JOIN FROM table1
RIGHT JOIN table2 ON table1.column_name =
table2.column_name;
Full outer join:
Retrieves all records when there is a match in either
the left or right table.
Syntax:
FULL OUTER
JOIN SELECT columns
FROM table1
FULL OUTER JOIN table2 ON table1.column_name =
table2.column_name;
SELECT column1, column2
FROM table1
WHERE condition1
FULL OUTER UNION ALL
SELECT columns
CROSS JOIN FROM table1
CROSS JOIN table2;
Self join :
Syntax :