tim r tim r - 2 months ago 18
SQL Question

Using add columns in phpMyAdmin

I was hoping to not have to go through the manual process creating more columns and was trying to use the following SQL script (inside phpMyAdmin). It says there is a syntax error but I have not found 1 working example of using add columns. I see lots of examples of "add column" but not multiple. Even when looking at the manual, I don't see where my syntax error is. thoughts?

ALTER TABLE assessment_info ADD COLUMNS
`condition` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_cuts` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_burns` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_infection` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_dermatitis` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_puncture` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_sprain` varchar(500) AFTER `non_rec_injuries_timeframe`
`rec_impact` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_cuts` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_burns` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_infection` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_dermatitis` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_puncture` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_sprain` varchar(500) AFTER `non_rec_injuries_timeframe`
`non_rec_impact` varchar(500) AFTER `non_rec_injuries_timeframe`
`cost_of_productivity` varchar(500) AFTER `non_rec_injuries_timeframe`
`leakage` varchar(500) AFTER `non_rec_injuries_timeframe`
`usage_rate` varchar(500) AFTER `non_rec_injuries_timeframe`
`cost_per_pair` varchar(500) AFTER `non_rec_injuries_timeframe`
`competitor` varchar(500) AFTER `non_rec_injuries_timeframe`

Answer

As far as I know, there is no ADD COLUMNS option to ALTER TABLE (see the documentation here).

You seem to intend:

ALTER TABLE assessment_info
    ADD COLUMN `condition` varchar(500) AFTER `non_rec_injuries_timeframe`,
    ADD COLUMN `rec_cuts` varchar(500) AFTER `non_rec_injuries_timeframe`,
    . . .