Leetcode Problem 1350. Students With Invalid Departments

1350. Students With Invalid Departments

Leetcode Solutions

LEFT JOIN and WHERE IS NULL

  • Perform a LEFT JOIN between Students and Departments on Students.department_id and Departments.id.\n- Use a WHERE clause to filter for rows where Departments.id is NULL, indicating that the department does not exist.\n- Select the relevant columns (Students.id and Students.name) from the result set.
\nerDiagram\n    Departments {\n        int id PK\n        varchar name\n    }\n    Students {\n        int id PK\n        varchar name\n        int department_id FK\n    }\n    Students }|--|| Departments : has\n

NOT IN Subquery

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...