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

VIEW with union all: selection problem

Status
Not open for further replies.

catalpa

Technical User
Oct 8, 2004
3
IT
This is an example of my view.

create view VIEWTEST as
select
'1' as TYPE,
TABLE1.KEYFIELD1 as KEYFIELD1,
'' as KEYFIELD2,
'' as KEYFIELD3,
TABLE1.FIELDX as FIELD1
from TABLE1
when TABLE1.FIELDS = TABLE2.FIELDS

union all SELECT
'2' as TYPE,
'' as KEYFIELD1,
TABLE2.KEYFIELD10 as KEYFIELD2,
'' as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))

union all SELECT
'3' as TYPE,
'' as KEYFIELD1,
'' as KEYFIELD2,
TABLE2.KEYFIEL10 as KEYFIELD3,
TABLE2.FIELDW as FIELD1
from TABLE2
where ((TABLE2.FIELDK = '1'))

My problem is that TABLE1 (TYPE 1)
occours only when TABLE2.FIELDK = '0' or TABLE2.FIELDK = '2' (only for union with TYPE='2')

I tried (row 11) with
when TABLE1.FIELDS = TABLE2.FIELDS and ((TABLE2.FIELDK = '0') or (TABLE2.FIELDK='2'))
but it doesn't work.
Any suggestion?

Thanks in advance
 
Is your problem simply that you have not included Table2 in the FROM list for the first section, so you cannot join to i?

Brian.
 
Yes!
I'm very sorry, I forgot to include table 2.
Excuse me, Brian, for this banal question.

Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top