Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server-2008
ID                                     EMAIL
_____________________________________________
EMAIL01                         xxx.xxx
EMAIL01A                      @xxx.com
 

Please help me to merge these two rows to create an email like this: xxx.xxx@xxx.com as a single row.
Posted 25-Feb-13 3:18am
Edited 25-Feb-13 6:24am
Mike Meinz23.2K
v3
Comments
joshrduncan2012 at 25-Feb-13 9:21am
   
What have you tried so far to accomplish this task?
ThePhantomUpvoter at 25-Feb-13 9:57am
   
Have you tried "EMAIL01 + EMAIL01A"?
ryanb31 at 25-Feb-13 10:08am
   
As suggested, just concatenate them together into a single row. Where exactly are you stuck?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is not enough information in the question to understand why a database table would be designed this way and what other rows are in the table that might need to be selected in a similar manner. Nevertheless, below is a Microsoft SQL Server SELECT statement that will concatenate the two rows in the manner that you specified in your question to create an email address.
 
Select (Select RTRIM(EMAIL) from table_1 where ID='EMAIL01') + (Select RTRIM(EMAIL) from table_1 where ID='EMAIL01A')
 
Note: Tested using Microsoft SQL Server Management Studio on SQL Server Express 2012
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

select (select ltrim(rtrim(Email)) from urTable where id='Email01') + (select ltrim(rtrim(Email)) from urTable where id='Email01A')
use this query
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Suppose your table is "THE_TABLE":
 

SELECT T1.ID, T1.EMAIL + T2.EMAIL FROM THE_TABLE T1 
  JOIN THE_TABLE T2 
     ON T2.ID = (T1.ID + 'A')
 
That should work Wink | ;)
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 495
1 Maciej Los 258
2 OriginalGriff 229
3 BillWoodruff 170
4 Zoltán Zörgő 165
0 OriginalGriff 7,934
1 DamithSL 6,084
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,174
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100