mysql refactor step1
sql refactor #2
sql refactor #3