Mysql 我有错误1242子查询返回超过1行

Mysql 我有错误1242子查询返回超过1行,mysql,sql,Mysql,Sql,我有错误1242,如果有人能帮我解决这个问题,因为它给我的系统带来了很多麻烦。 ty子查询中的行数不正确: 错误1242(ER_子选择第1行) SQLSTATE=21000 Message=“子查询返回多行” 对于子查询最多只能返回一行但返回多行的语句,会发生此错误。考虑下面的例子: select (select Nombre from Pacientes where idPacientes= any(select idPaciente

我有错误1242,如果有人能帮我解决这个问题,因为它给我的系统带来了很多麻烦。
ty

子查询中的行数不正确:

错误1242(ER_子选择第1行) SQLSTATE=21000 Message=“子查询返回多行” 对于子查询最多只能返回一行但返回多行的语句,会发生此错误。考虑下面的例子:

select (select Nombre 
        from Pacientes 
        where idPacientes= any(select idPaciente 
                                from Citas 
                                where Dias_idDia= any(select idDia 
                                                      from Dias 
                                                      where fecha = '2013-10-15'))) as 'Nombre',horaInicio, horaTermino,actividad,observacion,recordar,ciudad,tipoCita 
from Citas 
where Dias_idDia = any (select idDia 
                        from Dias 
                        where fecha='2013-10-15')
order by horaInicio;
如果SELECT column1 FROM t2只返回一行,则上一个查询将起作用。如果子查询返回多行,将发生错误1242。在这种情况下,查询应重写为:

SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);

你能给这个问题一些具体的答案吗?Leo的查询有什么问题?andy,但据我所知,Leo在所有3个子查询中都使用了
=ANY
。他没有在任何子查询中只使用
=
。那么哪个查询或子查询可能是错误的?@andy我很清楚这个事实。但当有人要求在他的查询中找出问题时(OP提供了SQL),提供的解决方案必须特定于他的SQL。特别是,如果OP是初学者。他没有问“当1242错误发生时?”他问“为什么我的SQL中会出现1242错误?”
SELECT * FROM t1 WHERE column1 = ANY (SELECT column1 FROM t2);
   select (select Nombre 
       from Pacientes 
       where idPacientes in (select idPaciente 
                            from Citas 
                            where Dias_idDia in (select idDia 
                                                  from Dias 
                                                   where fecha = '2013-10-15'))) as
  'Nombre',horaInicio, horaTermino,actividad,observacion,recordar,ciudad,tipoCita 
   from Citas 
   where Dias_idDia in (select idDia 
                    from Dias 
                    where fecha='2013-10-15')
   order by horaInicio;