在 mysql 中,如果存在,则在另一列之后添加该列

in mysql, add the column after the other column if exists

怎么可能?

我发现它是为了检查列是否存在

(
SELECT 1 FROM Information_schema.columns
WHERE table_schema = 'db' 
AND table_name = 'table' 
AND column_name = 'the other column'
)

并在另一列之后添加该列

ALTER TABLE 'table' ADD 'the column' VARCHAR(14) DEFAULT NULL AFTER 'the other column'

给出 table 所在的数据库的名称:-

ALTER TABLE db.table ADD the_column VARCHAR(14) DEFAULT NULL AFTER the_other_column

它对我有用试试这个,让我知道哪里失败了