Updated the SQL script to be compatible with older mysql versions