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
 

 

SQL Query for specific purpose

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

New User


Joined: 06 Jul 2005
Posts: 26
Location: Chennai

PostPosted: Thu Aug 11, 2005 10:32 am    Post subject: SQL Query for specific purpose
Reply with quote

Hi All,

I have 2 tables. In Table1 i have a column that has data in the following manner

colA
----
T1,T2,T3...
T4,T5
T6,T7,T8,T9...


in table 2 i have a unique column that has data in the following manner

colB
------
T1
T2
T3
T4
T5

Now what i need is i have to search in colA of table1 with the value taken from colB. If i dont have a match then i need to give the value of colB.

I need to accomplish this in a query.

Can you people help me out?
Back to top
View user's profile Send private message

sarath_ibm

New User


Joined: 03 Aug 2005
Posts: 14
Location: hyderabad

PostPosted: Thu Aug 11, 2005 10:13 pm    Post subject: hi
Reply with quote

I Dont Know correctly Try Right Outer join U May get the result
Back to top
View user's profile Send private message
ragshere

New User


Joined: 20 Dec 2004
Posts: 70

PostPosted: Wed Aug 17, 2005 7:05 pm    Post subject: Re: SQL Query for specific purpose
Reply with quote

Hi,
i am understanding the column in first table will contain values as a concatnation of values.
in this case You can LOCATE or POSSTR function to findout whether it contains value of column in second table.
You have to CASE statement in the query to display colB value if it is not found in first table.
Hope You understand what I am saying.

Thanks
Rags
Back to top
View user's profile Send private message
withnams

New User


Joined: 06 Jul 2005
Posts: 26
Location: Chennai

PostPosted: Wed Aug 17, 2005 7:16 pm    Post subject:
Reply with quote

Thanks. will try and let you know rags.
Back to top
View user's profile Send private message
vijayamadhuri

Active User


Joined: 06 Apr 2005
Posts: 180

PostPosted: Wed Aug 17, 2005 7:48 pm    Post subject: HI
Reply with quote

use the right outer join.This query will include rows from the table that have been specified after right outer join and with no matching values in the table.


select part,supplier,product.products.prod# from parts
right outer join products
on parts.prod#=products.prod#.
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Route a product's job to specific lpar vasanthz All Other Mainframe Topics 9 Thu Mar 02, 2017 2:22 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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