0
I need to make some changes in my bank, but before adding a new column I need to check if it already exists, if there is no create new column if there is no column then create
Command found to check column existence
SELECT COUNT(COLUMN_NAME) AS resultado FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'procedimentos_planos_tratamentos' AND COLUMN_NAME = 'tipo';
if the return is 1 do nothing and if the return is 0 perform following procedure
ALTER TABLE procedimentos_planos_tratamentos
ADD COLUMN tipo VARCHAR(1);
Here are some ways to do this https://stackoverflow.com/questions/24571611/mysql-alter-table-if-column-not-exists
– Bins