Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in writing Concatenation query 1

Status
Not open for further replies.

VIJSQL01

Programmer
Oct 30, 2010
74
US
Hi,

I am trying to execute a select query, that will have concatenation of four columns.

I am not just interested in concatenating, but also interested in inserting a constant values between these concatenations.
Also i want to have a word in between, which is again concatenated.

[highlight #CC0000]INPUT DATA[/highlight]

A = Tom, Dick, Harry............
B = Maria, Lucie, Diana............
Constant 1 = Palm
Constant 2 = Beach
C = Mike, Ron, Carmen............
D = Mary, Cynthia, Alex...........

[highlight #CC0000]I am expecting a result as follows,[/highlight]
Row 1 = Tom.Maria.Palm.MikeMary.Beach
Row 2 = Dick.Lucie.Palm.RonCynthia.Beach
Row 3 = Harry.Diana.Palm.CarmenAlex.Beach

I know the regular concatenation query such as CONCAT(A,'.',B,'.',C). Since i have to insert some constant in between, i am getting confused. And also, there a COncatenation under a concatentaion.

Your help will be really appreciated. Thanks in advance.

Best!

 
Hi,

CONCAT(A,'.',B,'.Palm.',C,'.',D,'.Beach')

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Awesome! it worked. Thanks a ton for rocket speed response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top