fix bug in assembling sql statement, and reload data into database