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

查看:65
本文介绍了mysql - 查询表里边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

解决方案

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

这篇关于mysql - 查询表里边id为16的content然后,更新id大于16的content为查出来的content的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆