查询表里边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;

推荐问题