0

我需要编辑数据库中某些表中特定列的值。

解释
我需要获取我的数据库中匹配“table_00”[00 是任意数字] 的所有表。
在这些表中,我需要找到任何具有product_nameas 的行ice cream
如果该product_description行不包含该单词cold,我需要将其添加到已经存在的值中

如何在管理员的 sql 命令中执行此操作?
谢谢你。

4

1 回答 1

1

尝试更新查询

<?php

function update($table)
  {
    $qry="UPDATE ".$table." SET product_description=concat(product_description, 'freezing cold') WHERE product_name='ice cream' AND product_description NOT LIKE '%cold%' ";
    mysql_query($qry) or die(mysql_error()."<br>".$qry);
  }
?>

并使用传递表名作为参数调用此函数

于 2013-04-22T11:46:55.400 回答