Changed SQL syntax to older versions