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

DB2 Query to concatenate two strings


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sakthivel_t100
Warnings : 1

New User


Joined: 03 Aug 2007
Posts: 10
Location: chennai

PostPosted: Wed Aug 22, 2007 10:43 pm
Reply with quote

Hi ALL,

I have one query. could you please answer for below query?

I have a emp table which column has value India Pakistan. I want result like IndiaPakistan. It should not be space between India and Pakistan. I need a query without using concentation fuction on DB2.

Thanks icon_mad.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 22, 2007 11:15 pm
Reply with quote

That requires a political and cultural answer. DB2 is only logical.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:18 pm
Reply with quote

So is the value in the column "India Pakistan" or are there 2 columns with values "India" and "Pakistan". And what is the reason for not using the concatenation function? It is there to be used.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:22 pm
Reply with quote

If it is 2 columns then

Code:

SELECT COLUMN A || COLUMN B
FROM empTable


It isn't use the concatenate function directly...
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:22 pm
Reply with quote

dbzTHEdinosauer: Shouldn't Kashmir be wedged between them?

IndiaKasmirPakistan?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Aug 22, 2007 11:28 pm
Reply with quote

Steve, from what I understand, that is part of the problem. India thinks Kashmir is part of India and Pakistan also claims Kashmir as a province.

I think the OP has only one column. Judicious use of substring would probably solve the problem, but having concatenation ruled out, I don't really believe this was a query about programming.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Wed Aug 22, 2007 11:30 pm
Reply with quote

Without substring, isn't there a replace function that would kill all the spaces?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 23, 2007 2:38 am
Reply with quote

Received two (2) PM's from sakthivel_t100.

He feels that I am trying to start trouble.

Well, first the restriction on the common sense use of the concatenation function.

Then, in his example he used the names of two nations that have political & cultural disagreements.

ok, i read too much into the question; not trying to start trouble. there is plenty of it around.

sakthivel_t100, don't send me any more of PM's.
Not please don't, just don't!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Aug 23, 2007 3:13 am
Reply with quote

Hello,

Please explain the business reason for this "rule"
Quote:
I need a query without using concentation fuction on DB2.


If there is no business requirement for this, you might let us know that it is something from school/training, an interview, or just an experiment that you are trying.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Aug 23, 2007 4:24 am
Reply with quote

Yeah I got a PM too. Oh well, it wasn't meant to be anything.
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
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top