userName -...

问题描述 投票:0回答:1
Appreciated to @dcp, i got my answer and would love to update if anyone else needs it.

我在SQL Server中有两个表,分别是用户和项目。我必须从另一个表的逗号分隔列中获取用户名,如下所示。tbl_Users

userID   |    userName
---------+------------
1        |  Thomas
2        |  Jack
3        |  James
4        |  Jones

tbl_Projects

projectID   |  projectName  | projectUsers
------------+---------------+-------------
5850        |  New Project  |    1,3
5895        |Another Project|    1,2,4

:projectUsers我需要输出 tbl_Projects 从5895人中选出 tbl_Users 的全名。

userID   |   userName
---------+-----------
1        |  Thomas
2        |  Jack
4        |  Jones

如下图所示。

如果有人能帮助我,我会非常高兴。
sql-server comma
1个回答
0
投票

在MSSQL中,我有两个表,其中有用户和项目。我必须从另一个表中获取用户名的逗号分隔字段,即如下所示。表tbl_Users userID

© www.soinside.com 2019 - 2024. All rights reserved.