SQL Joins Flashcards
(38 cards)
What does a JOIN operation do in Databricks SQL?
A JOIN operation in Databricks SQL combines rows from a left table with a right table based on specified join criteria.
What is the default join type in Databricks SQL?
The default join type in Databricks SQL is INNER JOIN, which returns only rows with matching values in both tables.
What is the difference between INNER JOIN and LEFT OUTER JOIN?
INNER JOIN returns only matching rows from both tables, while LEFT OUTER JOIN returns all rows from the left table and matched rows from the right, filling in NULLs for unmatched rows.
How does RIGHT OUTER JOIN differ from LEFT OUTER JOIN?
RIGHT OUTER JOIN returns all rows from the right table and matched rows from the left table, inserting NULLs where there is no match.
What is FULL OUTER JOIN in Databricks SQL?
FULL OUTER JOIN returns all rows from both tables, inserting NULLs in columns where there is no match from the other table.
What does LEFT SEMI JOIN return?
LEFT SEMI JOIN returns rows from the left table that have at least one match in the right table, without including columns from the right table.
What is the function of LEFT ANTI JOIN?
LEFT ANTI JOIN returns rows from the left table that do not have any match in the right table.
What result does a CROSS JOIN produce?
A CROSS JOIN returns the Cartesian product of two tables, combining each row of the first table with all rows from the second table.
What is the purpose of NATURAL JOIN in Databricks SQL?
NATURAL JOIN implicitly matches columns with the same names in both tables, combining rows with equal values in those columns.
What happens if you omit the join criteria in a JOIN operation?
If the join criteria is omitted, any JOIN type will behave like a CROSS JOIN, creating a Cartesian product.
How does the ON clause work in JOINs?
The ON clause defines a boolean condition that specifies how rows from the two tables should be matched.
What does the USING clause do in a JOIN?
USING clause matches rows by comparing equality across specified columns that must exist in both tables.
What effect does USING or NATURAL JOIN have on SELECT *?
Using USING or NATURAL JOIN removes duplicate columns from the result when SELECT * is used, showing matched columns only once.
What is a table alias in the context of JOINs?
A table alias is a temporary name assigned to a table in a JOIN, optionally with column identifiers for clarity or brevity.
What does a JOIN operation do in Databricks SQL?
A JOIN operation in Databricks SQL combines rows from a left table with a right table based on specified join criteria.
What is the default join type in Databricks SQL?
The default join type in Databricks SQL is INNER JOIN, which returns only rows with matching values in both tables.
What is the difference between INNER JOIN and LEFT OUTER JOIN?
INNER JOIN returns only matching rows from both tables, while LEFT OUTER JOIN returns all rows from the left table and matched rows from the right, filling in NULLs for unmatched rows.
How does RIGHT OUTER JOIN differ from LEFT OUTER JOIN?
RIGHT OUTER JOIN returns all rows from the right table and matched rows from the left table, inserting NULLs where there is no match.
What is FULL OUTER JOIN in Databricks SQL?
FULL OUTER JOIN returns all rows from both tables, inserting NULLs in columns where there is no match from the other table.
What does LEFT SEMI JOIN return?
LEFT SEMI JOIN returns rows from the left table that have at least one match in the right table, without including columns from the right table.
What is the function of LEFT ANTI JOIN?
LEFT ANTI JOIN returns rows from the left table that do not have any match in the right table.
What result does a CROSS JOIN produce?
A CROSS JOIN returns the Cartesian product of two tables, combining each row of the first table with all rows from the second table.
What is the purpose of NATURAL JOIN in Databricks SQL?
NATURAL JOIN implicitly matches columns with the same names in both tables, combining rows with equal values in those columns.
What happens if you omit the join criteria in a JOIN operation?
If the join criteria is omitted, any JOIN type will behave like a CROSS JOIN, creating a Cartesian product.