This is a discussion on Question about INFORMATION_SCHEMA within the MySQL forums, part of the Database Server Software category; --> What is wrong with this statement ? IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'creature_template' AND ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| What is wrong with this statement ? IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'creature_template' AND COLUMN_NAME = 'solo') THEN ALTER TABLE creature_template ADD COLUMN solo INTEGER(1) DEFAULT 0; END IF; This is the error message: /* Error: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'crea' at line 1" */ This is 5.0.45 on Windows. Thanks. |
| ||||
| Poster wrote: > What is wrong with this statement ? > > IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE > TABLE_NAME = 'creature_template' AND COLUMN_NAME = 'solo') THEN > ALTER TABLE creature_template ADD COLUMN solo INTEGER(1) DEFAULT 0; > END IF; > > This is the error message: > /* Error: "You have an error in your SQL syntax; check the manual that > corresponds to your MySQL server version for the right syntax to use > near 'IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE > TABLE_NAME = 'crea' at line 1" */ > > This is 5.0.45 on Windows. > Thanks. IF NOT EXISTS is only valid SQL as part of a CREATE statement. |