I write this query ALTER TABLE com_product DROP COLUMN drug_id; and then write this query but also error
ALTER TABLE com_product DROP COLUMN drug_id;
ALTER TABLE com_product DROP FOREIGN KEY drug_id;
but error
2
You can not delete this column because it is the key of another table. There is a link between this 2 tables. You must take off this constraint first or empty your table.
please remove your foreign key reference on column drug_id.
ALTER TABLE com_product DROP FOREIGN KEY `com_product_ibfk_2`;
Then remove the column.
ALTER TABLE com_product DROP COLUMN drug_id
Click here to cancel reply.
2
Answers
You can not delete this column because it is the key of another table. There is a link between this 2 tables. You must take off this constraint first or empty your table.
please remove your foreign key reference on column drug_id.
Then remove the column.