Fixed SQL for node deletion