neotam
neotam

Reputation: 2731

how to create dynamic columns in a table in mysql

I have a query, could you please tell me.

Upvotes: 0

Views: 1731

Answers (1)

Cynical
Cynical

Reputation: 9568

You can add a column to a table by using the ALTER TABLE command; add a column while you are doing an INSERT doesn't sound feasible to me, and even if it's possible I would descourage it. You should know which columns you are inserting values in before running the INSERT statement. My choice would be to ALTER your table before the INSERT statement.

That said, why are you needing this? I sense a disturbance in your database design, if you really need to add columns dynamically :)

Upvotes: 1

Related Questions