643 views
0 votes
0 votes
i got a doubt in understanding the sql concepts that "What does 'not exist' do in a sql query and does it work can anyone plz expain me with an example..??? plz

1 Answer

0 votes
0 votes

NOT EXISTS works like EXISTS, except the WHERE clause in which it is used is satisfied if no

rows are returned by the subquery.

For Ex.


SELECT Name
FROM Product
WHERE NOT EXISTS
    (SELECT *
     FROM ProductProductSubcategory
     WHERE ProductSubcategoryID =
            Product.ProductSubcategoryID
        AND Name = 'Wheels')

 The outer query will print the Name only for which inner Query returns 0 rows.