Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us