I'm trying to execute this query:
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.columns
WHERE table_name = 'MyTableName' AND column_name = 'ColumnInQuestion')
THEN ALTER TABLE MyTableName DROP COLUMN ColumnInQuestion;
And I get the following error message:
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 EXISTS(SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = 'articles'' at line 1
I'm using MySQL 5.1.something, so I don't think information_schema not being defined is the issue. Any ideas?
Thank you for your help!
IFin the context of DDL (at least I think so). According to the documentation - it is not possible to write such conditional DDLs.