Link to home
Start Free TrialLog in
Avatar of erenpasa
erenpasa

asked on

Add Column To Mysql Table

Hi to all,
I want to check field if not exists so add a field to table.
But i want to it just PURE SQL... with not php or etc...
is there any way?
/*
i want to add myfield  if it's not exists. just PURE SQL pls..
*/
ALTER TABLE mytable
ADD myfield varchar(20)

Open in new window

Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Just add it anyway. If the field exists, it will return an error. If it doesn't exist, it will add it. If this is part of some longer script, run it with mysql --force < file.sql
ASKER CERTIFIED SOLUTION
Avatar of erenpasa
erenpasa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial