How to use LEFT OUTER JOIN and IS NULL In SQL
The left join returns all the records in the left table whether they are matched or not. Using this, we can filter out the records for which the fields from the right table are NULL.
The following query employs the same to filter out the records for which hod.name is NULL.
SELECT professor.* FROM professor
LEFT OUTER JOIN hod
ON professor.name=hod.name
WHERE hod.name IS NULL;
Output:
Explanation: The output consists of employee records from the professor table where the name does not match any name in the hod table, using a LEFT OUTER JOIN and filtering for NULL values in the hod table.
How to Select Rows that Don’t Exist in Other Table in PostgreSQL?
In PostgreSQL, there are times when we need to find records in one table that do not exist in another table. This can be useful for various data manipulation tasks and ensuring data integrity.
In this article, we will explore different approaches along with examples to achieve this using PostgreSQL. By the end, you will have a clear understanding of how to efficiently select rows that don’t exist in another table which help to improve your data management skills in PostgreSQL.