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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Partial result

Status
Not open for further replies.

niccos

Programmer
Joined
Nov 29, 2003
Messages
1
Location
IT
Hi to all.
I have a view like this:

create view TableALL as
select * from TableA union all select * from TableB


and I have this query:

SELECT MMCODMAG,MMCODART,MMVALMAG,MMQTAMOV
FROM TableALL
WHERE (MMCODMAG IN ('30110','30111','30112')) AND (MMDATREG>='20021201' AND MMDATREG<'20030101')


Well, if I run the query on TableA I find 27065 records, if I run it on TableB I have 18650 records. If I run it on the view TableAll I have only the record from TableA (27065).

Also if I create the view TableB union TableA, I obtain only the records of B (18650).

Thanks
Niccos
 
Niccos -

Are Tables A and B identical in structure (all the same fields, in the same native order)? If not, try creating the view with specifically named fields, rather than with &quot;select *&quot;:

create view TableALL as
select MMCODMAG,MMCODART,MMVALMAG,MMQTAMOV, MMDATREG
from TableA
union all
select MMCODMAG,MMCODART,MMVALMAG,MMQTAMOV, MMDATREG
from TableB

John
 
Have a look at the query plan and see what is generated.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top