IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SQL Query for specific purpose


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
This topic is locked: you cannot edit posts or make replies. Construct new record using specific f... DFSORT/ICETOOL 6
Search our Forums:

Back to Top