Click here to Skip to main content
13,141,576 members (53,001 online)
Rate this:
 
Please Sign up or sign in to vote.
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
Updated 25-Feb-13 5:24am
Mike Meinz26.7K
v3
Comments
joshrduncan2012 25-Feb-13 9:21am
   
What have you tried so far to accomplish this task?
ThePhantomUpvoter 25-Feb-13 9:57am
   
Have you tried "EMAIL01 + EMAIL01A"?
ryanb31 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 ;)
  Permalink  
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
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