What is the difference between INNER JOIN and OUTER JOIN?

Question

can you help me with this question

 

Answer ( 1 )

    0
    2025-02-22T06:01:41+00:00
    • INNER JOIN returns only matching records from both tables.
    • OUTER JOIN returns all records from one or both tables, filling non-matching rows with NULLs.

    📌 Example:

    -- INNER JOIN (Only common records)
    SELECT employees.name, department.dept_name
    FROM employees
    INNER JOIN department ON employees.dept_id = department.dept_id;
    -- LEFT JOIN (All employees, even those without a department)
    SELECT employees.name, department.dept_name
    FROM employees
    LEFT JOIN department ON employees.dept_id = department.dept_id;

Leave an answer