UNION ALL



IBM's flagship relational database management system

UNION ALL

Postby Shakthivel V » Sun Nov 07, 2010 2:12 pm

Hi Everybody,
I have a requirement such as to fetch persons details such as last name,
first name etc, and his addresses. Each person can have five addresses. I
have to get all the details for all the patient in a single database
transaction. Also i Have to order by personcode which is unique for each
person. For this I tried something like this but it gives oracle exception -
The query i used is

Select 1, A.personcode, A. lastname, A. fistname FROM table1 A where
A.perosncode IN (1,2) ORDER BY A.personcode
Union All
Select 2, A.personcode, B.street1, B.street2 FROM table2 B where
B.personcode IN (1,2) ORDER BY B.personcode

I get the error as ORA-00900 : invalid SQL statement.

Any suggestions welcom..

Thanks in Advance
Shakthivel V
 
Posts: 22
Joined: Thu Mar 04, 2010 12:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: UNION ALL

 

Re: UNION ALL

Postby NicC » Sun Nov 07, 2010 4:41 pm

For starters how about:
1 - cutting and pasting your query as you have errors in your column names as posted
2 - using the code tags to present your query in a fixed font so everything lines up
3 - I presume you need to match the personcode columns on both tables (WHERE A.PERSONCODE = B.PERSONCODE)
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: UNION ALL

Postby dick scherrer » Sun Nov 07, 2010 10:12 pm

Hello,

Which database is being used?

The ORA-00900 is an Oracle error not DB2. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: UNION ALL

Postby GuyC » Tue Nov 09, 2010 3:31 pm

Select 2, A.personcode, ... FROM table2 B ...
will be rather difficult
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post