如何更新mysql数据库? [英] How do I update a mysql db?

查看:244
本文介绍了如何更新mysql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How do I update a mySQL database with  new values, but the unchanged rows should be left as it is and need to update changed rows and need to add new rows if the record is not available.



我是初学者并给我一个基本的想法请


I am a beginner and Give me a basic idea please

推荐答案

不完全确定你在问什么,似乎需要2个答案



1)直接更新



请参阅 MySQL :: MySQL 5.7参考手册:: 13.2.11更新语法 [ ^ ] - 用SQL执行SQL更新'确保只有特定行更新的'子句 - 因为你没有提供其他信息,例如表名,模式,不能真正帮助你更多的东西



2)另一个可能更好的选项是MySQL INSERT ... ON DUPLICATE KEY UPDATE语句类型: MySQL :: MySQL 5.7参考手册:: 13.2.5 INSERT语法 [ ^ ]
Not exactly sure what you're asking, seems like 2 answers are required

1) a straight update

see MySQL :: MySQL 5.7 Reference Manual :: 13.2.11 UPDATE Syntax[^] - you do an SQL update with a 'where' clause to make sure only particular rows are updated - since you provide no other information eg table name, schema, cant really help you more on it

2) Another option that may be better is a MySQL INSERT ... ON DUPLICATE KEY UPDATE type of statement per : MySQL :: MySQL 5.7 Reference Manual :: 13.2.5 INSERT Syntax[^]


这篇关于如何更新mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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