SQL JOIN - WHERE clause vs. ON clause

前端 未结 19 1607
深忆病人
深忆病人 2020-11-21 11:56

After reading it, this is not a duplicate of Explicit vs Implicit SQL Joins. The answer may be related (or even the same) but the question is diffe

19条回答
  •  既然无缘
    2020-11-21 12:42

    In SQL, the 'WHERE' and 'ON' clause,are kind of Conditional Statemants, but the major difference between them are, the 'Where' Clause is used in Select/Update Statements for specifying the Conditions, whereas the 'ON' Clause is used in Joins, where it verifies or checks if the Records are Matched in the target and source tables, before the Tables are Joined

    For Example: - 'WHERE'

    SELECT * FROM employee WHERE employee_id=101
    

    For Example: - 'ON'

    There are two tables employee and employee_details, the matching columns are employee_id.

    SELECT * FROM employee 
    INNER JOIN employee_details 
    ON employee.employee_id = employee_details.employee_id
    

    Hope I have answered your Question. Revert for any clarifications.

提交回复
热议问题