本文介绍了在SQL中连接两行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ID&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP EMAIL

_____________________________________________

EMAIL01&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP&NBSP xxx.xxx

EMAIL01A                       &xbsp @ xxx.com





请帮我合并这两行来创建像这样的电子邮件:[email protected]作为单行。

ID                                     EMAIL
_____________________________________________
EMAIL01                         xxx.xxx
EMAIL01A                      @xxx.com


Please help me to merge these two rows to create an email like this: [email protected] as a single row.

推荐答案

Select (Select RTRIM(EMAIL) from table_1 where ID=''EMAIL01'') + (Select RTRIM(EMAIL) from table_1 where ID=''EMAIL01A'')





注意:在SQL Server Express 2012上使用Microsoft SQL Server Management Studio进行测试



SELECT T1.ID, T1.EMAIL + T2.EMAIL FROM THE_TABLE T1
  JOIN THE_TABLE T2
     ON T2.ID = (T1.ID + 'A')





那应该有用;)



That should work ;)


这篇关于在SQL中连接两行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 03:20