【问题标题】: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

谢谢

【问题讨论】:

  • 是的。它被称为update

标签: 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 语句用新值更新命名表中现有行的列

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-13
        • 1970-01-01
        • 2019-03-11
        • 1970-01-01
        • 1970-01-01
        • 2021-01-30
        • 1970-01-01
        相关资源
        最近更新 更多