简体   繁体   English

SQL Server串联联接

[英]SQL Server Concatenate Join

I want to create a left join between a concatenate result of two columns of the main table and another column of the second table. 我想在主表的两列与第二个表的另一列的连接结果之间创建左联接。 My question is, should this join affect the query performance? 我的问题是,此联接是否会影响查询性能? Is there any better way to do it? 有什么更好的方法吗?

Table A: Column1, Column2
Table B: Column3

Select *
from Table A left Outer Join
     Table B on Column1+Column2=Column3

I appreciate your help. 我感谢您的帮助。

Thanks 谢谢

This is fine, 这可以,

For SQL Server 对于SQL Server

Select *
from `Table A` as a left Outer Join
     `Table B` as b on a.Column1 + a.Column2 = b.Column3

For MySQL use concat() 对于MySQL,请使用concat()

Select *
from `Table A` as a left Outer Join
     `Table B` as b on concat(a.Column1,a.Column2) = b.Column3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM