如何在Mysql中建立self到self关系?
我正在使用 Heidi,我有这个表:
表类别:
- id
- 标题
- parent_id
字段parent_id 是id 的引用。这样我就可以实现类别和子类别的无限层次结构。如何在 mysql 语法中创建这种关系?
I am using Heidi and I have this Table:
Table Category:
- id
- title
- parent_id
The field parent_id is a reference of id. This way I can do a unlimited Hierarchy of category and sub-category. How do I create this relationship in mysql Syntax?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的意思是如何创建外键约束,您只需要执行以下操作:
If you mean how do you create the foreign key constraint, you just need to do something like this: