1

mysql表示例:

<table>
  <tr>
    <td>id</td>
    <td>value</td>
  </tr>
  <tr>
    <td>aa</td><td>1111</td>
  </tr>
  <tr>
    <td>bb</td><td>1111</td>
  </tr>
  <tr>
    <td>cc</td><td>2222</td>
  </tr>
  <tr>
    <td>dd</td><td>3333</td>
  </tr>
  <tr>
    <td>ee</td><td>1111</td>
  </tr>
</table>
<br />

我是新来的,想知道是否有任何可以帮助我用 php 替换 1111s 到 4444s 的值。

我尝试了以下方法,但似乎没有用:

$sql="UPDATE tablename SET id= REPLACE( id,'1111','4444')";

4

3 回答 3

2

you should replace the value,not the ID

$sql="UPDATE tablename SET `value` = REPLACE(`value`,'1111','4444')";

or simply

$sql="UPDATE tablename SET `value` = '4444' WHERE value = '1111'";
于 2013-02-21T16:15:41.420 回答
0
UPDATE tablename SET value = "4444" WHERE value = "1111"
于 2013-02-21T16:16:07.373 回答
0
UPDATE tablename
SET    value='4444'
WHERE  value='1111'
于 2013-02-21T16:16:50.993 回答