modifing sql queries