I am working with a correlated and a non-correlated subquery in SQL and I am trying to get the same results with both types of queries. My issue is with my non-correlated subquery. The query runs but does not return any results. My correlated subquery does return results, like it should. I need help trying to figure out if my simple non-correlated subquery is written incorrectly. Any help is greatly appreciated. My queries are as follows:
--non-correlated subquery
SELECT *
FROM hr.bc_products p
WHERE p.sku NOT IN (SELECT ol.sku FROM hr.bc_orderlines ol);
--correlated subquery
SELECT *
FROM hr.bc_products p
WHERE NOT EXISTS (SELECT ol.sku FROM hr.bc_orderlines ol WHERE ol.sku = p.sku);
SELECT p.* FROM hr.bc_products p LEFT JOIN hr.bc_orderlines ol ON p.sku = ol.sku WHERE ol.sku IS NULL