本文主要是介绍【MySQL】Subquery returns more than 1 row 解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题提出:
有如下需求,在同一张表中,当某个字段的值符合一定条件时,修改另一个字段的值。
SQL:update topic set topi_closed = 1 where topi_id = (select topi_id from (select * from topic) as b where now() > topi_stilltime and topi_closed = 0)
运行结果:
当有多个符合查询条件时会报如下错误:Subquery returns more than 1 row (子查询返回多行1)
解决方案:添加any方法,如下
SQL:update topic set topi_closed = 1 where topi_id = any(select topi_id from (select * from topic) as b where now() > topi_stilltime and topi_closed = 0)
MySQL的子查询:all、any、some
详情链接:http://blog.csdn.net/c517984604/article/details/7052186
这篇关于【MySQL】Subquery returns more than 1 row 解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!