MySQL add column if not exist
If your host doesn’t give you permission to create or run procedures, I think I found another way to do this using PREPARE/EXECUTE and querying the schema: SET @s = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name=”table_name” AND table_schema = DATABASE() AND column_name=”col_name” ) > 0, “SELECT 1”, “ALTER TABLE table_name ADD col_name VARCHAR(100)” … Read more