query differences

G

geebee

hi,

I have 2 queries. names are make_history and up_tbl_masterpop_main. I am
trying to decipher the differences, as they return not exactly the same
number of rows. can someone tell me the difference/logic?

make_history query:
SELECT
tbl_masterpop_new.[Loan Acct #], tbl_masterpop_new.Status,
tbl_masterpop_new.PopEnterDt
other column names...
FROM tbl_masterpop_new LEFT JOIN tbl_masterpop_main
ON tbl_masterpop_new.[Loan Acct #] = tbl_masterpop_main.[Loan Acct #]
WHERE tbl_masterpop_main.[Loan Acct #] is Null
UNION ALL SELECT
tbl_masterpop.[Loan Acct #], tbl_masterpop.Status, tbl_masterpop.PopEnterDt,
other column names...
FROM tbl_masterpop LEFT JOIN tbl_masterpop_main
ON tbl_masterpop.[Loan Acct #] = tbl_masterpop_main.[Loan Acct #]
WHERE tbl_masterpop_main.[Loan Acct #] is Null;

up_tbl_masterpop_main query:
up_tbl_masterpop_main:
SELECT tbl_masterpop.[Loan Acct #]
, tbl_masterpop.[Status]
,tbl_masterpop.[PopEnterDt],
other column names...
FROM tbl_masterpop LEFT JOIN tbl_masterpop_new
ON tbl_masterpop.[Loan Acct #] = tbl_masterpop_new.[Loan Acct #]
WHERE tbl_masterpop_new.[Loan Acct #] is Null
UNION ALL SELECT tbl_masterpop_new.[Loan Acct #]
, tbl_masterpop_new.[Status]
,tbl_masterpop_new.[PopEnterDt],
other column names...
FROM tbl_masterpop_new LEFT JOIN tbl_masterpop
ON tbl_masterpop_new.[Loan Acct #] = tbl_masterpop.[Loan Acct #]
WHERE tbl_masterpop.[Loan Acct #] is Null;

anyone who can answer this gets huge bonus points!

thanks in advance,
geebee
 
J

Jerry Whittle

FROM tbl_masterpop_new LEFT JOIN tbl_masterpop
and
FROM tbl_masterpop LEFT JOIN tbl_masterpop_main

They are running against 2 sets of different tables. Unless the table data
is exactly the same, then you would expect differences.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

query from form 8
query speed 5
nested query 9
query problems 1
join type not supported 5
delete query 1
query error 3
query addition 1

Top