Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count deleted records after a DELETE

I try to count how many records will be deleted after a DELETE command:

SELECT COUNT(*) FROM BOXES
WHERE EXISTS  ( 
    DELETE FROM BOXES WHERE product='25043620' AND Order='0846'
)

I get an syntax error near delete, but I can't figure out which is it.

like image 608
yaylitzis Avatar asked Dec 14 '22 07:12

yaylitzis


1 Answers

After some digging, I figured out... after

DELETE FROM BOXES WHERE product='25043620' AND Order='0846'

I ask database for changes with:

SELECT changes()

and I get how many rows was deleted.

like image 195
yaylitzis Avatar answered Jan 13 '23 13:01

yaylitzis