PostgreSQL NOT IN ConditionIn this section, we are going to understand the working of PostgreSQL NOT IN condition, and example of Not IN condition with Numeric and Character values. Introduction of PostgreSQL NOT IN conditionThe PostgreSQL NOT IN condition is used with WHERE clause to fetch data from a table where defined condition contradicts the PostgreSQL IN condition. PostgreSQL NOT IN Condition SyntaxIn PostgreSQL, the NOT IN condition can be used with the SELECT, INSERT, UPDATE and DELETE commands. Example of PostgreSQL NOT IN Condition: with Numeric valuesThe PostgreSQL NOT IN Operator is used to fetch those rows whose values do not match the list's values. For this, we are taking the department table from the Javatpoint database. The following example displays Not IN Operator's use to identify the department information whose emp_id is neither 1 nor 2: Output On executing the above command, we will get the below output displaying those records whose emp_id is neither 1 nor 2. Similarly, we can also use the AND Operator and NOT EQUAL (<>) Operator instead of NOT IN operator as we can see in the following statement: Output On implementing the above statement, we will get a similar output compared to the above query output: Example of PostgreSQL NOT IN Condition: with Character valuesFor this, we are taking the employee table as above to get that employee information whose emp_fname does not relate to James, Mia employees. We are using the NOT IN operator in the WHERE clause as we can see the following command: Output On executing the above command, we will get the following result: In the above example, the PostgreSQL NOT IN condition will return all rows from the employee table where the emp_fname is neither 'James' nor 'Mia'. OverviewIn the PostgreSQL NOT IN Condition section, we have learned the following topics:
Next TopicPostgreSQL BETWEEN Condition |