MySQL artırmak satırları değiştirin

2 Cevap php

Ben aşağıdaki tablo vardır: http://kimag.es/share/59074317.png

sütunlar = [id cid Yorum]

Ben tablodaki her satır için 1 CID değerlerini (comment id) bir artış yapmak için bir yol gerekir.

Satır 1, cid = 0

satır 2, cid = 1

satır 3, cid = 2

vb

Bu php script Şimdi cid = id:

<?php
$con = mysql_connect("localhost","MYUSER","MYPASS");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$id=0;
$totalrows=23207; 

mysql_select_db("MYDB", $con);
while($id < $totalrows)
{
$sql = "UPDATE comments SET cid=$id WHERE id=$id";
mysql_query($sql,$con);
$id++;
}

mysql_close($con);
?>

Birisi uygun bir mysql sorgusu verebilir misiniz?

Note: I don't have any 'individual keys'... and I need the cid to correspond to a specific comment so I can delete it, modify it, vb (yes, I should've thought of that before creating the table >_<).

Teşekkürler!