Fix sql statements