有没有办法查询数据库以在列表中列出培训师计划,或者这是我们应该在 Visual Basic 中做的事情
我被告知要使用 sql 和/或 Visual Basic 执行此操作,我尝试使用一些奇怪的 for 和 foreach 或 while 循环,但没有走得很远。从项目中我们应该使用纯 c# 或 sql 仅此而已。
我目前创建了一个 SQL 查询:
SELECT
Trainers.ID, Trainers.FirstName, Trainers.LastName, Trainers.Phone,
Trainers.Hours, TrainerPlan.PlanID
FROM
FitnessPlans
INNER JOIN
(Trainers INNER JOIN TrainerPlan ON Trainers.ID = TrainerPlan.TrainerID) ON FitnessPlans.ID = TrainerPlan.PlanID;
其中有一个导致此结果的培训师列表:
ID FirstName LastName Phone Hours PlanID
--------------------------------------------------------------
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 1
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 2
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 3
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 4
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 5
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 6
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 7
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 8
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 3
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 5
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 6
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 7
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 8
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 1
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 2
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 3
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 4
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 5
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 6
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 3
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 5
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 6
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 7
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 8
它应该看起来像这样:
1 Calvin Hodges 765-495-1234 MWF: 8 am - 4 pm 1,2,3,4,5,6,7,8
2 Brittany Saxony 765-495-9876 TH: 8 am - 4 pm 3,5,6,7,8
3 Jacob Golden 765-495-1111 MTWHF: 4 pm - 12 am 1,2,3,4,5,6
4 Lisa Harris 765-494-0987 MTWHF: 4 pm - 12 am 3,5,6,7,8
有任何想法吗?