I'm using MySQL 5.5.15. I have a .sql file I'm using as part of an installer. I need to check whether the database exists or not.
If it doesn't exist then create a new database and tables.
If it DOES exist then update the database tables with additional columns.
I'd like to check this with a simple IF statement:
If NOT EXISTS(SELECT SCHEMA_NAME from INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'MyDatabase')
Why doesn't this work? The problem is the IF statement. It seems logical to me but I'm obviously thinking differently than MySQL.