Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I count the number of deleted rows in a MYSQL query?

I'm trying to find out whether a delete query executed properly. I know how many rows its supposed to delete, and I'd like to check that the number that were deleted, matches what's expected, from within the query itself.

How do I find out the number of rows that I just deleted, from within a SQL query running against MySQL? Separate statements are fine, as long as I can bundle them into one query.

like image 886
blueberryfields Avatar asked Nov 24 '11 20:11

blueberryfields


People also ask

How can I count deleted records in MySQL?

You can use ROW_COUNT() function to check the number of deleted rows. The conditions in the WHERE clause (optional) identify which rows to delete. Without WHERE clause, all rows are deleted. If you specify the ORDER BY clause, the rows are deleted in specified order.

How do I count the number of rows returned in a SQL query?

In SQL Server, you can use T-SQL's COUNT() function to return the number of rows that would be returned in a query.

How can I count deleted records in SQL Server?

Step 1: Use the beneath referenced command to check the number of rows present in the table from which the data got erased. Step 3: Collect all the data about the erased records from the SQL Server table to recover data. By using this command, you will acquire a Transaction ID of deleted records.


1 Answers

see MySQL ROW_COUNT function here http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_row-count

like image 197
Jan Turoň Avatar answered Oct 21 '22 11:10

Jan Turoň