Title: MySQL affected rows
Last modified: August 19, 2016

---

# MySQL affected rows

 *  [wesg](https://wordpress.org/support/users/wesg/)
 * (@wesg)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/mysql-affected-rows/)
 * Is there a way to use this MySQL command for WordPress queries? Right now using
   $wpdb it returns as “improper syntax”.

Viewing 1 replies (of 1 total)

 *  [Roger Theriault](https://wordpress.org/support/users/rogertheriault/)
 * (@rogertheriault)
 * [17 years, 11 months ago](https://wordpress.org/support/topic/mysql-affected-rows/#post-804726)
 * The return value of the query should give that number. The [$wpdb class](http://codex.wordpress.org/Function_Reference/wpdb_Class)
   is in the wp-db.php file. Apparently some class attributes are created on the
   fly… try
 * `$wpdb->rows_affected` (for insert/delete/update/replace)
 * `$wpdb->num_rows` (number of rows returned for select)
 * `$wpdb->insert_id` (id of last inserted/replaced record)
 * `$wpdb->last_error`
 * `$wpdb->print_error()`
 * And you may find more gems in the code.

Viewing 1 replies (of 1 total)

The topic ‘MySQL affected rows’ is closed to new replies.

 * 1 reply
 * 2 participants
 * Last reply from: [Roger Theriault](https://wordpress.org/support/users/rogertheriault/)
 * Last activity: [17 years, 11 months ago](https://wordpress.org/support/topic/mysql-affected-rows/#post-804726)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
