What does a CROSS JOIN do?
It performs a Cartesian Product between two inpute tables.
SQL Server 70-461 04-01
What is the syntax for a CROSS JOIN?
SELECT Tbl1.col1, Tbl2.col2
FROM Tbl1
CROSS JOIN Tbl2;
You don’t have to select just one column per table, you can select all if you want. For row 1 from Tbl1 a row will be returned for however many rows are in tbl2. The rows will contain data from Tbl1 row 1 and data from each row of Tbl2. This happens for every row in Tbl1.
SQL Server 70-461 04-01
What do you need to do in a self-join?
SQL Server 70-461 04-01
What word can be ommitted from INNER JOIN and still produce the same result?
Since an INNER JOIN is the most common type of join, the word INNER can be ommitted. If you put JOIN only, the default meaning is INNER JOIN.
SQL Server 70-461 04-01
What is the difference between a primary key and a foreign key w/ regard to indexes?
SQL Server 70-461 04-01
How does LEFT OUTER JOIN work?
SQL Server 70-461 04-01
how does a RIGHT OUTER JOIN work?
Same as left, just opposite.
SQL Server 70-461 04-01
What is the equivalent of LEFT OUTER JOIN?
SQL Server 70-461 04-01
How does FULL OUTER JOIN wok and what is another equivalent?
SQL Server 70-461 04-01
How does a multi join query work?
SQL Server 70-461 04-01
What is the older syntax for an INNER JOIN and should the old or new syntax be used?
Old
- A comma between the table names in the FROM clause and the predicates in the WHERE clause.
NEW
- T1 INNER JOIN T2
- Use the new syntax. With the old syntax, if you forget to put a predicate in the WHERE clause you will create an unintentional cross join.
SQL Server 70-461 04-01
What rows does an INNER JOIN return?
Matching rows for which the predicate evaluates to true. False and unknown are discarded.
SQL Server 70-461 04-01
For an INNER JOIN, should you place your predicates in the ON or WHERE clause?
SQL Server 70-461 04-01
How does an outer join work?
SQL Server 70-461 04-01
How does the ON clause differ when used in a LEFT OUTER JOIN vs an INNER JOIN?
SQL Server 70-461 04-01
What does the ON clause decide in a LEFT OUTER JOIN?
SQL Server 70-461 04-01
How does an INNER JOIN work?
SQL Server 70-461 04-01
What is the old syntax for a CROSS JOIN and should you use the old or new syntax?
Old
FROM T1, T2
NEW
FROM T1
CROSS JOIN T2
Use the new version, it is less prone to errors and more consistent
SQL Server 70-461 04-01
How is the WHERE clause different in LEFT OUTER JOIN vs INNER JOIN?
SQL Server 70-461 04-01
What can you do if your multi-join query isn’t coming out as expected?
SQL Server 70-461 04-01
What is a Cartesian Product?
Result Table
Col 1 | Col 2
A | B1
A | C1
A | C2
A | D1
B | B1
B | C1
B | C2
B | D1
C | B1
C | C1
C | C2
C | D1
SQL Server 70-461 04-01