查询表里边id为16的content然后,更新id大于16的content为查出来的content

1.使用sql只查询一次
2.我自己的sql:

 UPDATE guideline_news
    SET content = (
        SELECT
            content
        FROM
            guideline_news
        WHERE
            id = 16
    )
    WHERE
        id > 16

备注:
这个sql报错:[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT content FROM guideline_news WHERE id=16 WHERE id>16' at line 1

阅读 1.9k
1 个回答

update guideline_news set content =(select content from (select * from guideline_news) a where a.id = 16) where id>16;

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题