I have a table for posts as (id, category_id, ...), then JOIN
it with the category table as (category_id, category_name, parent, ...) ON category_id
. Parent is the category_id of another category. For example:
category_id category_name parent
1 Computer Science NULL
2 Web Technology 1
3 Mathematics NULL
4 PHP 2
How can I JOIN
posts and category tables to read parent categories of a post too. For example,
id category_id post_title
44 4 something
With simple JOIN
ON category_id, I can get only PHP as category; how can I get the parents too as Computer Science > Web Technology > PHP
?
NOTE: I use mysql with MyISAM engine.