0

この 2 つのクエリがあり、それらを結合する方法がわかりません。どうぞ:

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";

手伝ってくれてどうもありがとう。

4

1 に答える 1

1

1 つのステートメントに複数の結合を含めることができるため、2 つのステートメントを組み合わせて次を取得できます。

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";
于 2013-02-16T09:22:52.067 に答える