DROP PROCEDURE IF EXISTS update_migration;
DELIMITER //
CREATE PROCEDURE update_migration ()
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = `bid_log` AND COLUMN_NAME = `Paid` ) THEN
ALTER TABLE `bid_log` ADD `Paid` INT NULL;
END IF;
END //
DELIMITER ;
I'm using SELECT 1 FROM the schema table to check if a column exists, but if the column doesn't exist, I get this error:
ERROR 1054 (42S22) at line 1: Unknown column 'bid_log' in 'where clause'
How can I check for an existing column without mysql throwing an error for having a missing value in my select query?