时间:2020-10-31 17:15:04 | 栏目:MsSql | 点击:次
表A
A1 | A2 | A3 | A4 |
01 | 02 | 03 | 04 |
03 | 04 | 01 | 02 |
表B
B1 | B2 |
01 | 张三 |
02 | 李四 |
03 | 王五 |
04 | 赵六 |
显示结果
A1 | A2 | A3 | A4 |
张三 | 李四 | 王五 | 赵六 |
王五 | 赵六 | 张三 | 李四 |
效果图:
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了