Fixed all the sql statements