putting together sql query for deleting in delete function