• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

concatination of 3 fields in SQL query

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guyz,
i wanted to concatenate 3 fields and display the result. but concat() is taking only two fields as parameter. i want to concat first_name,last_name,mid_name.
can any body suggest answer for it.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
better do it in your code instead.
dont know for other databases. in oracle we use pipleline to concat.
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
select concat(concat(f_name,m_name),l_name) from table_name where ....


Hope it helps
Beksy
 
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I prefer to do this in application side and not in sql query.
But if you want to do this, you can use like this



Correct me if I am wrong
Hope this help

daniel
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will prefer to use StringBuffer as using concat on String should be avoided.

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shailesh,
I dont understand about your query...



According to my experience, there is no keyword StringBuffer in SQL keywords.
StringBuffer is Java object and we cannot mix that into our sql query.

I think we can use StringBuffer to compose that name in application side.
After we receive ResultSet, we can get first_name, mid_name and last_name.
And then using StringBuffer to compose that value...

Correct me if I am wrong to understand your words
thanks
daniel
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Fisher Daniel:
Hi Shailesh,
I dont understand about your query...

According to my experience, there is no keyword StringBuffer in SQL keywords.



daniel

I think We both are on different frame....
as adeel said
better do it in your code instead.

So my reply was in same context

and I was suggesting to make a query in code



However It was mistake that after seeing your query I interpreted that same is being formed in Java. sorry for my mistake
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:



Actually, what i was trying to say is something totally different.
Use of concat() function or pipelines might be database specific or somehow differs among databases. might be.

thats why i said better do it in your code. it means just simply query the db like this,

then in you code do this,


cheers.
 
syam ganna
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
O.K. Thanks Guys.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic