SQL SERVER 表与表之间 字段一对多sql语句写法

前端之家收集整理的这篇文章主要介绍了SQL SERVER 表与表之间 字段一对多sql语句写法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

表A

表B

显示结果

效果图:

sql语句如下

sql;"> SELECT (SELECT B2 FROM B WHERE B1=A1) AS A1,(SELECT B2 FROM B WHERE B1=A2) AS A2,(SELECT B2 FROM B WHERE B1=A3) AS A3,(SELECT B2 FROM B WHERE B1=A4) AS A4 FROM A

这样就ok了

原文链接:https://www.f2er.com/mssql/62716.html

猜你在找的MsSQL相关文章