Monday, 10 September 2012

Difference between ON and WHERE in sql statements

Hi All,
We generally find the difference between the ON and WHERE statements in sql when JOIN's are used.
WHERE - eliminates rows from the result set
ON - is applied on the join statement only



WHERE is a part of the SELECT query as a whole, ON is a part of each individual join.
ON can only refer to the fields of previously used tables.
When there is no actual match against a record in the left table, LEFT JOIN returns one record from the right table with all fields set to NULLSWHERE clause then evaluates and filter this.

Refer below links for more clarification