Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Records not returned by UNION query

Status
Not open for further replies.

Aqif

Programmer
Apr 27, 2002
240
AU
Hi

I have two queries

1. SELECT ADMDIAG AS ReadCode FROM TblSurgicalForm WHERE ADMDIAG Is Not Null

Returns me 1235 records

2. SELECT ADMDIAG2 AS ReadCode FROM TblSurgicalForm WHERE ADMDIAG2 Is Not Null

Returns me 133 records

But when I try to combine them in to one query like

SELECT ADMDIAG AS ReadCode FROM TblSurgicalForm WHERE ADMDIAG Is Not Null

UNION

SELECT ADMDIAG2 AS ReadCode FROM TblSurgicalForm WHERE ADMDIAG2 Is Not Null

It returns me 518 records. In my view it should return me 12385+133=1368 records

Where I am doing wrong..any help appreciated


Cheers!
ÙÇãá

It's important to learn the rules so that you know how to break them.
 
Hi,

Just saw some help and came to know that UNION query will automatically remove duplicates. So t saves me one step



Cheers!
ÙÇãá

It's important to learn the rules so that you know how to break them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top