Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Syntax Problem in union query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Mon Sep 17, 2007 6:02 pm    Post subject: Syntax Problem in union query
Reply with quote

hi,

I am trying to do union of two queries, but i am facing syntax problem

please correct the following query

SELECT * FROM
(SELECT ABC,DEF FROM X.TABLE1
WHERE ABC=313742
UNION ALL
SELECT ABC,DEF FROM X.TABLE2
WHERE ABC=825748 AS TEMP1)
TEMP1 ;

Thanks in advance

Regards
JR
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Sep 17, 2007 6:23 pm    Post subject:
Reply with quote

Hello,

Do not use "Urgent" in a topic title. One way or another most of the topics are "urgent".

Please post some sample data and the result you want when your query executes.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Mon Sep 17, 2007 6:28 pm    Post subject:
Reply with quote

Hi There,

Please give

Code:
SELECT ABC,DEF FROM X.TABLE1
WHERE ABC=313742
UNION ALL
SELECT ABC,DEF FROM X.TABLE2
WHERE ABC=825748
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Mon Sep 17, 2007 8:08 pm    Post subject:
Reply with quote

Thanks Ekta...

Is the query will work when i select quallified rows by doing check(condition) on mulitiple tables

like where x.a=y.a and
y.b=Z.b
Z.c=x.c..etc

on union is it possible.

Please let me know thanks..
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Tue Sep 18, 2007 8:13 am    Post subject: Reply to: Problem in union query
Reply with quote

rajandhla,

Quote:
on union is it possible.

you dont wanna do that with Union, if indeed you wanna select records for same values for any column you dont need Union.

May be, if you post your specific requirements we can help better.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us