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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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