sql - JOIN inside WHERE vs outside WHERE -
will both statements return same results?
the top code has join in clause , takes on 4 hrs run. moving join outside same query runs in 1m 6s. have not seen join in clause.
note dsa.doc_id child version record of orders.folder.
--old code taking 4+ hrs run select top 1 status_to_date dsa (status_to = 'ca') , left(dsa.doc_id,12) = orders.folder --new code taking less minute select top 1 status_to_date dsa left outer join orders on left(dsa.doc_id,12) = orders.folder (status_to = 'ca')
yes believe both queries give same result. , in side join gives slowest result. there 1 more alternate of above query willl nmore , more faster second query too
select top (1) status_to_date dsa (status_to = 'ca') , (select count(*) orders orders.folder = left(dsa.doc_id,12)) > 0
Comments
Post a Comment