【问题标题】:change content of a sql column to all the same将 sql 列的内容更改为完全相同
【发布时间】:2015-11-19 13:12:57
【问题描述】:
我在表名 oc_product 中有一个名为 (status) 的列
此列连接到我的产品为 1= actif 0=inactif
现在我希望我的 sql 数据库中的列全部为 0,所以 al 将是 inactif
更改列中所有内容(状态)的代码也是如此,因此该列中的所有内容都必须为 0
谢谢
【问题讨论】:
标签:
mysql
sql
multiple-columns
【解决方案1】:
UPDATE
oc_product
SET
status = 0
--it feels dirty not putting a WHERE clause here, but this is the answer
【解决方案2】:
UPDATE oc_product SET status = 0
这应该可以解决问题。由于没有 WHERE 子句,oc_product 中所有记录的status 值将设置为 0。
编辑:您可能需要像 [status] 一样转义 status。我不太习惯mysql的语法细节,所以可能status是关键字,需要转义。
【解决方案3】:
使用 MySQL Update
UPDATE oc_product SET status = 0;
UPDATE 语句用新值更新命名表中现有行的列