问题描述
我有两个表,它们是
1)学生(student_no(主键),student_name)
2)phoneDetails(student_no(外键,电话号码)
学生表具有这样的记录
1 raj
2拉尼
3巴布
phonedetails表具有这样的记录
1 3434556
2 4555667
1 4567566
3 5678908
2 5623468
2 1234565
一个学生可以有多个电话号码,我想用逗号分隔的值来获取这些电话号码,
我想得到的结果是
1 raj 3434556,4567566
2 rani 4555667,5623468,1234565
3 babu 5678908
请通过SQL Server查询帮助我.
I have two tables they are
1) student(student_no (primary Key) ,student_name)
2) phoneDetails(student_no (Foreign Key,phone no)
student table has the records like this
1 raj
2 rani
3 babu
phonedetails table has the records like this
1 3434556
2 4555667
1 4567566
3 5678908
2 5623468
2 1234565
A student can have multiple no of phone numbers,I would like to get these numbers in comma separated values,
I would like to get the result as
1 raj 3434556,4567566
2 rani 4555667,5623468,1234565
3 babu 5678908
Please help me through SQL Server queries.
推荐答案
这篇关于如何从Sql Server-2005中的两个表中获取逗号分隔的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!