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
 

 

DB2 Query to concatenate two strings

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Query to concatenate two strings
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Aug 23, 2007 3:13 am    Post subject:
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    Post subject:
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    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