mysql - Inserting multiple columns in the table error with query -


this query:

alter table  `mytable` add   `telephone` varchar( 50 ) not null, `date_of_annual_health_care_plan` date not null, `first_language` varchar ( 50 ) not null, `interp_req` int not null, `religion` varchar ( 50 ) not null, `religious_considerations` varchar ( 350 ) not null, `diagnosis_and_associated_health_conditions` varchar ( 500 ) not null, `communcation` varchar ( 350 ) not null, `challenging_behaviours` varchar ( 350 ) not null, `medicare_number` varchar ( 50 ) not null, `pension_number` varchar ( 50 ) not null, `private_health_insurance` varchar ( 50 ) not null, `person_responsible` int not null, `person_res_name` varchar ( 50 ) not null, `person_res_address` varchar ( 50 ) not null, `person_res_telephone_h` varchar ( 50 ) not null, `person_res_telephone_w` varchar ( 50 ) not null, `person_res_telephone_m` varchar ( 50 ) not null, `person_res_email` varchar ( 50 ) not null, `decision_making_function` varchar ( 250 ) not null, `relative` varchar ( 50 ) not null, `guardian_name` varchar ( 50 ) not null, `guardian_address` varchar ( 50 ) not null, `guardian_telephone_h` varchar ( 50 ) not null, `guardian_telephone_w` varchar ( 50 ) not null, `guardian_telephone_m` varchar ( 50 ) not null, `guardian_email` varchar ( 50 ) not null ; 

and getting following error:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'date_of_annual_health_care_plan date not null, first_language varchar ( 50 ' @ line 3

why receiving error?

you need prefix add column before each column in order add multiple columns in 1 statement, so:

alter table  `mytable` add column `telephone` varchar( 50 ) not null, add column `date_of_annual_health_care_plan` date not null, ... 

also, don't think need backticks everywhere, since none of names conflict reserved words.

sqlfiddle


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -