mysql 报错 ‘u'Subquery returns more than 1 row'’

Posted webbky

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 报错 ‘u'Subquery returns more than 1 row'’相关的知识,希望对你有一定的参考价值。

watch_course_sql = """select  DATE_FORMAT( FROM_UNIXTIME(a.CreateTime / 1000) , %%Y-%%m-%%d %%T) regtime,
    a.username
FROM
    bskuser a
where
    a.UserName
in
    (select
        username
          from
            bskchapterlist
                where
                    lessonid =
                        (select
                                id
                            from
                                bsklesson a
                            WHERE
                                a.lessonname like \%s\)
                            )
limit   %d,50

""" % (coursename, page*50)

 

前台传来的coursename应该是汉字

但是如果错误传来number的时候 

后台会报错 
    
‘uSubquery returns more than 1 row’        只需在在相关的位置加个any就行啦
最终的sql语句
  
select  DATE_FORMAT( FROM_UNIXTIME(a.CreateTime / 1000) , %Y-%m-%d %T) regtime,
            a.username username
        FROM
            bskuser a
        where
            a.UserName
        in
             (select
                username
                  from
                    bskchapterlist
                        where
                            lessonid =
                                ANY (select
                                        id
                                    from
                                        bsklesson a
                                    WHERE
                                        a.lessonname like %2%)
                                    )

 

相关资料:http://stackoverflow.com/questions/778239/mysql-subquery-returns-more-than-one-row






以上是关于mysql 报错 ‘u'Subquery returns more than 1 row'’的主要内容,如果未能解决你的问题,请参考以下文章

MySQL 报错: Subquery returns more than 1 row

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

Mysql5.7 CentOS7 报错:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (u

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery

mysql报错 1142 - SELECT command denied to user 'root_ssm'@'localhost' for table 'u