mysql - drop column only if exists in sql -
guys totally newbie .. want delete column in table if exists ... here know alter table men drop column lname how make if exists in sql ??
what want not possible in pure mysql-syntax. however, if using api or back-end in application. can following.
if (select count(*) table_name.columns table_schema = 'database_name' , table_name = 'table_name' , column_name = 'column_name'>0) begin alter table table_name drop column column_name end
Comments
Post a Comment