Use correct condition in delete sql