-1
$res=mysql_query("select * from table where id>10");

I can delete associated records using only $res ?

I mean i do not want make another query like delete * from table where id>10 so in this way $res can be used to get data, and then delete records.

note :: instead of clicking 'close' to close question, consider understand the question first, is a valid question and not was posted before. :genius:

4

2 回答 2

1

You can't. The reason is that the resource you get is for the mysql_* PHP extension, and doesn't actually refer to data, a command, or anything on the server. They are completely separate. MySQL doesn't care or know how these things are implemented on the MySQL client.

于 2013-05-22T01:27:05.803 回答
0

You could take the associated records from your query, run a loop on them and delete as needed. Not sure if that helps with what you're trying to do?

<?
$res = mysql_query("SELECT * FROM table WHERE id>10"); 
$rescount = mysql_num_rows($res);
$resloop = 0;

while ($resloop < $rescount){

//do any additional logic here and then add delete statement if desired for the specific record

$resloop++;
}
?>
于 2013-05-22T02:29:44.230 回答