Adjust sql for newer MySQL