---
title: "How to add manually related posts to a post?"  
description: "How to add manually related posts to a post?"  
author: "Anonymous User"  
published: 2013-05-10  
updated: 2013-05-10  
canonical: https://www.mindstick.com/forum/860/how-to-add-manually-related-posts-to-a-post  
category: "php"  
tags: ["php"]  
reading_time: 2 minutes  

---

# How to add manually related posts to a post?

Hi Guys\
I am designing a blog site in php where [users](https://www.mindstick.com/news/2244/issue-preventing-users-from-accessing-facebook-s-social-networking-platforms-has-been-resolved) can add manually related posts to a post.\
I thought to use an [auto increment](https://www.mindstick.com/forum/193/auto-increment-by-store-procedure) [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) for all posts related.\
This is the [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap):\
Blog:-id-related ( it's 0 if there aren't related posts or it contain an auto incremet integer that it is the same for all posts related )-id_user-[title](https://www.mindstick.com/articles/12860/how-to-get-financing-for-salvage-title-cars)-body-dateI prefer not to use a "related table" if possible to [avoid](https://yourviews.mindstick.com/story/1518/tips-to-avoid-dengue-at-home) [complex](https://yourviews.mindstick.com/audio/1142/understanding-the-complex-factors-influencing-mental-health) queries.\
So I need a way to get an auto increment integer in this case or you can [suggest me](https://www.mindstick.com/interview/23114/can-you-suggest-me-few-top-directory-submission-site) other [solutions](https://www.mindstick.com/articles/12807/product-searching-issues-and-solutions-for-ecommerce-store-advanced-search-autocomplete-suggest) :)\
Thanks\

## Replies

### Reply by AVADHESH PATEL

Hi Pravesh!\
Why not have a second table? It's probably the most robust solution, and it doesn't complicity your queries much at all.\
You should have a second table, related-posts, with two fields: original and related.\
Neither are unique, so the following is possible (assuming 1,2,3,4 are post IDs)\
o | r----1 | 21 | 32 | 32 | 44 | 1When you need to find posts related to post 1 (for example), you query\
SELECT `related` FROM `related-posts` WHERE `original` = 1;This will give you all related post IDs.\
This kind of relationship is called many-to-many relationship, one post can have many related posts, and one post can be related to many original posts.\


---

Original Source: https://www.mindstick.com/forum/860/how-to-add-manually-related-posts-to-a-post

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
