码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2017-05-13 12:24:45      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:course   ons   stack   mysql   ber   color   div   for   lis   

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'’

标签:course   ons   stack   mysql   ber   color   div   for   lis   

原文地址:http://www.cnblogs.com/wanghaonull/p/6848442.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!