S
S
Silverlight892020-05-14 12:25:03
MySQL
Silverlight89, 2020-05-14 12:25:03

How to properly link mysql tables?

The PHPMyAdmin database has two tables, articles and comments, which share a page _id column. I want to link them through this column with this query:
ALTER TABLE `comments` ADD FOREIGN KEY (`page_id`) REFERENCES `articles`(`id`) ON DELETE RESTRICT ON UPDATE RESTRICT;
MySQL Answer: Documentation #1452.
What am I doing wrong and how to connect them correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Gordinskiy, 2020-05-14
@DmitriyGordinskiy

Make sure that for each page_id value in comments there is a corresponding id in articles.

D
d-stream, 2020-05-14
@d-stream

I think the answer is contained in the documentation #1452

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question