I have a table for posts and a table for categories, what i want is to select posts that are in a specific category. The problem is that the category is stored in another table and not in the posts table, here is the example:
posts
id title body
---------------------------
125 Some title Blah blah
categories
postid category
----------------
125 politic
I want in single query to fetch posts in the politic category by example, what to do?
Use:
The issue I have with your CATEGORIES table is that storing the category value as a string means the data isn’t normalized – you should instead have a CATEGORY table:
CATEGORY
…and use the
category_idvalue in theCATEGORIEStable:CATEGORIES