覆盖MySQL表中的数据 [英] Overwriting data in a MySQL table

查看:481
本文介绍了覆盖MySQL表中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的查询中,我试图用值NEW_VALUE覆盖名为"login"的MySQL表中的第10个字段.没用下面的代码是否是覆盖MySQL表中现有数据的正确方法?

With the query below, I am trying to overwrite the 10th field in a MySQL table called "login" with the value NEW_VALUE. It's not working. Is the code below the correct method for overwriting existing data in a MySQL table?

预先感谢

约翰

INSERT INTO login VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'NEW_VALUE', NULL, NULL, NULL)

推荐答案

没有您的代码不正确.您正在向表中添加新行,而不更新现有值.要更新现有值,您想使用一条update语句:

No your code is not correct. You are adding a new row to your table not updating existing values. To update existing values, you want to use an update statement:

更新特定记录

mysql_query("Update login SET nameOfYourColumn = '$cleanURL' WHERE primaryKey = idOfRowToUpdate")

要更新整个表格

mysql_query("Update login SET nameOfYourColumn = '$cleanURL'")

这篇关于覆盖MySQL表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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