Good day buddy! I got a new article for you. This one is about SQL language used in manipulating the data in your database. There are several useful keywords in SQL but today I'll just share with you the function of SQL NOT IN keyword. In creating an information system, there will be several cases wherein you need to specify a certain condition in your query and there will be cases wherein you need to negate those conditions. One example is the NOT IN keyword that I will explain briefly on the second paragraph. Another examples are NOT EQUAL, NOT BETWEEN, NOT LIKE, IS NOT NULL, NOT EXIST, and NOT UNIQUE. But, in this article, we will just be focusing on the NOT IN keyword. I’ll be posting articles for other keywords soon so better keep watching.
The SQL NOT IN keyword is used to return records that are not present on the other table. Let's say you want to display the records from the left table which is the ENROL table which are NOT IN the right table which is the SUBMIT table.
STUDENT and ENROLL Table
![]() |
STUDENT |
![]() |
ENROL |
Syntax SQL NOT IN
select * from table1 where id NOT IN (select id from table2)
Query SQL NOT IN
select * from student where stud_id NOT IN (select stud_id from enrol)
The output displays records of students that are not yet enrolled or student that have no record on the second table.
Hope this helps! ^_^
Output:
No comments:
Post a Comment