2

询问

    DELETE FROM TEMPSchedules 
           WHERE StudentID = ( Select StudentID 
                               From Students 
                               Where Ref = 'H1007')

错误信息

子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。

问题

现在的问题是每个“参考组”都有超过 1 个学生附属于它。那么我应该如何处理这个问题。谢谢

4

3 回答 3

5
  DELETE FROM TEMPSchedules 
           WHERE StudentID  in ( Select distinct StudentID 
                               From Students 
                               Where Ref = 'H1007')
于 2012-11-01T11:05:25.647 回答
0
DELETE TEMPSchedules
From Students 
Where Students.Ref = 'H1007' and Students.StudentID=TEMPSchedules.StudentID
于 2012-11-01T11:43:46.143 回答
0

以下 SQL 语句仅从“Students”表的“StudentID”列中选择 DISTINCT 值,其中 Ref = 'H1007': SELECT DISTINCT StudentID FROM Students;

于 2018-04-21T11:51:43.423 回答