joins1 - JOINS CARTESIAN PRODUCT A Cartesian product is...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: JOINS CARTESIAN PRODUCT A Cartesian product is formed when: s A join condition is omitted s A join condition is invalid s All rows in the first table are joined to all rows in the second table s To avoid a Cartesian product, include a valid join condition in a WHERE clause. b Ex:Employees CARTESIAN PRODUCT Departments Employees X Departments >(Cross product – without any JOIN condition) Joins b Write the join condition in the WHERE clause b Prefix the column name with the table name when the same column name appears in more than one table. b Provide Alias name for the table rather than having entire table name as prefix. b Rows in one table Joined to rows in another table according to common values existing in corresponding columns (usually primary and foreign key columns) b To join n tables together, you need minimum of n-1 join conditions b Syntax: s SELECT table1.column, table2.column FROM table1, table2 WHERE table1.column1 = table2.column2 ; Types of Join b Equijoin (Simple join, Inner join) (=) b Nonequijoin(other than =) b Outer join (+) b Self join Tables Employees Departments Locations EQUI – JOIN b Display the location name of the dept where the employees works b SELECT e.lastname, d.d_name, l.city FROM employees e, departments d, locations l WHERE e.dept_id = d.dept_id AND d.location_id = l.location_d ; •Equi joins removes null values....
View Full Document

This note was uploaded on 04/01/2012 for the course CSE,IT 101 taught by Professor Mirunaalini during the Spring '12 term at Indian Institute of Technology, Chennai.

Page1 / 30

joins1 - JOINS CARTESIAN PRODUCT A Cartesian product is...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online