MySQL里IN子查询使用LIMIT

如题,本来可以用一条SQL语句完成的为什么非得拆开呢?

本来想这样写的

UPDATE `t1` SET `recommend` = 1 WHERE `id` IN(
    SELECT `id` FROM `t1` WHERE `userid` = 176 ORDER BY `id` LIMIT 5)

却提示This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’

不让这么用,那么再加一层呢?

UPDATE `t1` SET `recommend` = 1 WHERE `id` IN(
    SELECT * FROM (
        SELECT `id` FROM `t1` WHERE `userid` = 176 ORDER BY `id` LIMIT 5) AS t2)

居然成功了???

关于Burgess Lee

人能常清静 天地悉皆归
此条目发表在技术相关分类目录,贴了, 标签。将固定链接加入收藏夹。