以特定格式检索数据的查询
我有两张桌子。员工信息和技能
员工信息包含以下详细信息 - ID(唯一标识符)、名字、姓氏。
技能具有以下详细信息 - 员工 ID、技能组
示例数据如下:
Employee Information
Id FirstName LastName
1 John Connor
2 Thomas Anderson
Skills
EmployeeId Skillset
1 CRM
1 SQL Server 2000
1 .NET 3.5
2 Java
2 Hibernate
我需要如下输出:
1 John Connor CRM, SQL Server 2000, .NET 3.5
2. Thomas Anderson Java, Hibernate
我运行 SQL Server 2000。无论如何,我可以借助查询而不是使用游标来完成此操作。
I have two tables. Employee Information and Skills
Employee Information has the following details - ID (Unique Identifier), FirstName, LastName.
Skills has the following details - Employee Id, Skillset
A sample data will be as follows:
Employee Information
Id FirstName LastName
1 John Connor
2 Thomas Anderson
Skills
EmployeeId Skillset
1 CRM
1 SQL Server 2000
1 .NET 3.5
2 Java
2 Hibernate
I need my output as follows:
1 John Connor CRM, SQL Server 2000, .NET 3.5
2. Thomas Anderson Java, Hibernate
I run SQL Server 2000. Is there anyway, that I can do this with the help of a query rather than use cursors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,仅使用一条 SQL 语句是无法做到这一点的。您可以使用光标来完成此操作,但在应用程序代码中执行此操作可能是最简单的。
No, there is no way to do this with just a single SQL statement. You could do it with cursors, but it would probably be easiest to just do it in your application code.