A Different Approach to Subqueries With Oracle 12c

Thanks to Emrah Mete
When writing queries in database versions, we couldn’t use correlated subqueries in the FROM section of our query. With Oracle 12c, this is addressed.
https://dzone.com/articles/a-different-approach-to-subqueries-with-oracle-12c

SELECT *
FROM hr.employees e,
LATERAL
(SELECT * FROM hr.departments WHERE department_id = e.department_id) x
WHERE x.department_name =’Public Relations’;

SELECT *
FROM hr.employees e
CROSS APPLY
(SELECT * FROM hr.departments WHERE department_id = e.department_id) x;

SELECT *
FROM hr.employees e
OUTER APPLY
(SELECT * FROM hr.departments WHERE department_id = e.department_id) x;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s