This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

concatination of 3 fields in SQL query  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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: 1085
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 1085
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
O.K. Thanks Guys.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!