不等于操作员不工作

时间:2015-09-28 06:19:07

标签: sql sql-server sql-server-2008

SP:

INNER JOIN StudentSubjectMapping SS ON SM.StudentID=SS.StudentID  
WHERE SM.CourseID=@CourseID OR @CourseID=0
  AND SM.ClassID=@ClassID OR @ClassID=0
  AND SM.ClassSectionID=@ClassSectionID OR @ClassSectionID=0
  AND SD.StudentID <> SS.StudentID

4 个答案:

答案 0 :(得分:4)

尝试在以下内容中添加括号$('.mobile-nav-toggle').on('click', function() { var status = $(this).hasClass('is-open'); if (status) { $('.mobile-nav-toggle, .mobile-nav').removeClass('is-open'); } else { $('.mobile-nav-toggle, .mobile-nav').addClass('is-open'); } });

()

答案 1 :(得分:1)

使用LEFT JOIN代替

    LEFT JOIN StudentSubjectMapping SS ON SM.StudentID=SS.StudentID  
    WHERE SM.CourseID=@CourseID OR @CourseID=0
      AND SM.ClassID=@ClassID OR @ClassID=0
      AND SM.ClassSectionID=@ClassSectionID OR @ClassSectionID=0
      AND SS.StudentID IS NULL

答案 2 :(得分:1)

您可以使用NOT IN选择StudentIDs中不存在的StudentSubjectMapping

INNER JOIN StudentSubjectMapping SS ON SM.StudentID=SS.StudentID  
WHERE (SM.CourseID=@CourseID OR @CourseID=0)
  AND (SM.ClassID=@ClassID OR @ClassID=0)
  AND (SM.ClassSectionID=@ClassSectionID OR @ClassSectionID=0)
  AND (SD.StudentID NOT IN (SELECT StudentID FROM StudentSubjectMapping))

答案 3 :(得分:1)

感谢您的支持。回答:

WHERE
    (SM.CourseID=@CourseID OR @CourseID=0)
    AND
    (SM.ClassID=@ClassID OR @ClassID=0)
    AND
    (SM.ClassSectionID=@ClassSectionID OR @ClassSectionID=0)
    AND
    SM.StudentID NOT IN (SELECT StudentID FROM StudentSubjectMapping)