Skip to content
Advertisement

column “parent_id” referenced in foreign key constraint does not exist when creating SQL table

I am new in SQL and trying to understand Foreign key syntax. I know this was asked in multiple questions but each question I found did not seem to teach me what I am doing wrong here. This is my SQL code:

And this is the error I am getting:

Advertisement

Answer

You need to add fields in your tables to make the reference. Something like this :

This is simply the reason why it’s not working.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement