fixed sql statements to work with mysql