我有两个查询,我不知道如何将它们连接在一起。 他们在这里:
command.CommandText = "
SELECT sl.Reg_No,sr.ID_Number,sr.Name,sr.Course,sl.Date,sl.Time_IN,sl.Time_Out,sl.ScheduleId
FROM student_logs sl
INNER JOIN student_records sr ON sl.Student_Reg_No=sr.Reg_No
WHERE sl.date between '" & fromDateTimePicker.Value.ToShortDateString & "' and '" & toDateTimePicker.Value.ToShortDateString & "'
ORDER BY Reg_No DESC";
command.CommandText = "
SELECT sls.StudentLogStatusDescription
FROM studentlogstatus sls
INNER JOIN student_logs sl ON sls.StudentLogStatusId=sl.StudentLogStatusId
ORDER BY Reg_No DESC";
非常感谢你的帮助。
答案 0 :(得分:1)
您可以在一个语句中拥有多个联接,因此您可以将这两个语句组合起来:
command.CommandText =
"SELECT sl.Reg_No,sr.ID_Number,sr.Name,sr.Course,sl.Date,
sl.Time_IN,sl.Time_Out,sl.ScheduleId,sls.StudentLogStatusDescription
FROM student_logs sl
INNER JOIN student_records sr ON sl.Student_Reg_No=sr.Reg_No
INNER JOIN studentlogstatus sls
ON sls.StudentLogStatusId=sl.StudentLogStatusId
WHERE sl.date between '" & fromDateTimePicker.Value.ToShortDateString &
"' and '" & toDateTimePicker.Value.ToShortDateString & "'
ORDER BY Reg_No DESC";