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 ta
Use:
SELECT p.id,
p.title,
p.body
FROM POSTS p
JOIN CATEGORIES c ON c.postid = p.id
WHERE c.category = 'politic'
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:
...and use the category_id value in the CATEGORIES table: