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 2:18am
Edited 25-Feb-13 5:24am
Mike Meinz20.7K
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 OriginalGriff 414
1 Maciej Los 180
2 Richard MacCutchan 140
3 DamithSL 129
4 Kornfeld Eliyahu Peter 119


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