Hi, i am creating a web app with php and mysql. My problem is to this three tables: categories, subcategories and posts: Category has many subcategories, subcategory belongs to one category, category has many posts, post belongs to only one category subcategory belongs to one category, post belongs to one subcategory I have attached schema of all three tables , so my question is: How can I insert a post just in specified category (not in subcategory) ? Thnx.
With the table-setup you show us, you can't. Simply because under the post-table, you do not directly connect to the main category table (you connect to a subcategory, which THEN connects to the main category table). You will have to remake the tables a bit for what you're asking to work.