douling1936 2013-02-18 11:48
浏览 93

寻求一种有效的方法来查找受mysql UPDATE操作影响的行

I am using php.

$sql = "UPDATE `table` SET `field` = 'value' WHERE `item_id` IN (comma separated list of item_ids)";

If I execute the above query, how can I find out which item_id's where updated? Note that some of the id's in the comma separated list of item_ids do not exist in the 'table' otherwise the answer would be trivially every id in the comma separated list.

I am using the mysql api where you connect via mysql_connect().

  • 写回答

1条回答 默认 最新

  • doupeng8494 2013-02-18 11:52
    关注

    use mysql_affected_rows(). it will return the table's incremented id's array which are affected in the last query.

    评论

报告相同问题?