PL/SQL Exists

Oracle PL/SQL Exists Example

Exists Example 1:

SELECT *
FROM customers c1
WHERE EXISTS (Select *
				From contracts c2
				Where c1.customer_id = c2.customer_id
			);

Not Exists Example 2:

SELECT *
FROM customers c1
WHERE NOT EXISTS (Select * 
					From contracts c2
					Where c1.customer_id = c2.customer_id);

Exists Example 3:

UPDATE offers o	
SET o.amount =	o.amount*2
WHERE EXISTS
(SELECT c.customer_id
	FROM customers c
	WHERE c.customer_id = o.customer_id
);