subquery - Correlated vs Non-correlated subqueries in SQL -


i working correlated , non-correlated subquery in sql , trying same results both types of queries. issue non-correlated subquery. query runs not return results. correlated subquery return results, should. need trying figure out if simple non-correlated subquery written incorrectly. appreciated. queries follows:

--non-correlated subquery

select * hr.bc_products p p.sku not in (select ol.sku hr.bc_orderlines ol); 

--correlated subquery

select *  hr.bc_products p not exists (select ol.sku hr.bc_orderlines ol ol.sku = p.sku); 

i figured out issue was. after looking through results of each query realized nulls affecting outcome. updated non-correlated subquery excluding nulls. updated non-correlated subquery works , looks this:

--non-correlated subquery

select * hr.bc_products p p.sku not in (select ol.sku hr.bc_orderlines ol ol.sku not null); 

hopefully avoid problem in future.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -