• Login

DataSoft Corporation

NOT

Using the NOT keyword with the EXISTS keyword allows you to test whether rows do not exist in the result of the subquery. For every row, the outer query evaluates Pervasive PSQL tests for the existence of a related row from the subquery. Pervasive PSQL excludes from the statement's result table each row from the outer query that corresponds to a related row from the subquery.

Including the NOT keyword along with the IN operator allows you to test whether the result of the outer query is not included in the result of the subquery. The result table for the statement includes only rows the outer query returns that do not have a related row from the subquery.

Examples

The following statement returns a list of students who are not enrolled in any classes:

SELECT * FROM Person p WHERE NOT EXISTS 
(SELECT * FROM Student s WHERE s.id = p.id 
AND Cumulative_Hours = 0)

 

This statement can be rewritten to include IN:

SELECT * FROM Person p WHERE p.id NOT IN 
(SELECT s.id FROM Student s WHERE Cumulative_Hours = 0)
Thursday, 18 April 2019 Posted in Pervasive SQL Command
 DataSoft Store  Knowledgebase  Contact Us
 Sitemap  Privacy Policy
    Customer Service


Copyright © 2019 DataSoft Corporation All rights reserved.