Many users use my softwares (on their local machines) and the databases are not at the same level. There are people who haven't upgraded the software (and the database) for more than one year then suddenly decide to upgrade.
For every software version I save the MySql structure changes but I might commit errors too so I need a "conditional" structure change especially for
Alter table xxx add field1 varchar(200);
In the case above if the field exists it will raise an error and the next command won't finish.
I know that I can check it in the INFORMATION_SCHEMA but I wonder how can I put this together in an Sql statement.
SELECT count(*) into @isExists FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA="xxx" and TABLE_NAME = "yyy" AND COLUMN_NAME = "zzz";
and then check the variable somehow?
I want the same for create tables as well.