-2

I created table and added all data in it but forgot to add foreign key what to do?

There is id column in both table one table consists primary key and second table consists related data but forgot to add foreign key and when I try to print all combined data it's not working

Shadow
  • 33,525
  • 10
  • 51
  • 64

1 Answers1

0

So if you created Id column in both tables and you forgotten to add foreign key then you can basically use following query

ALTER TABLE table_child 
    ADD FOREIGN KEY(Id) REFERENCES table_parent(Id)

You can add your table names at table_child and table_parent.

Hope this help you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Baki_s
  • 16
  • 1