Search code examples
javamysqlsql-delete

Finding number of deleted rows by a query


Earlier I had 2000 records.

After I fired below query, I would be having 1500 records.

DELETE FROM logInfo WHERE datediff(now(), whatTime) >= 2

Is there any query which would tell me how many records are deleted by above records?

I know I can use below query before delete command, however I am just curious is there any other way to find after deletion.

SELECT COUNT(*) FROM logInfo WHERE datediff(now(), whatTime) >= 2

I need this in JAVA or MYSQL.

I know in php it would be mysql_affected_rows()


Solution

  • The preparedStatement.executeUpdate() returns the number of affected rows.