Here are my tables
Note
This tables are for example only
Posts
++++++++++++++++++++++++++++++++++++++++
+ id |title | desc | uid |status |
++++++++++++++++++++++++++++++++++++++++
+ 1 | a | aaaa | 1 | 1 |
++++++++++++++++++++++++++++++++++++++++
+ 2 | b | bbbb | 1 | 1 |
++++++++++++++++++++++++++++++++++++++++
+ 3 | c | cccc | 2 | 1 |
++++++++++++++++++++++++++++++++++++++++
Cats
+++++++++++++++++++++++++++++++++
+ id | name |parent | status |
+++++++++++++++++++++++++++++++++
+ 1 | cat1 | 0 | 1 |
+++++++++++++++++++++++++++++++++
+ 2 | cat2 | 0 | 1 |
+++++++++++++++++++++++++++++++++
Tags
+++++++++++++++++++++++++
+ id | name | title |
+++++++++++++++++++++++++
+ 1 | tag1 |ttitle |
+++++++++++++++++++++++++
+ 2 | tag2 |title2 |
+++++++++++++++++++++++++
Linked_data
Linked as one 2 multi relation ship
Link Name
postid
cat_or_tag_id
+++++++++++++++++++++++++++++
+ name | r1 | r2|
+++++++++++++++++++++++++++++
+ cat | 1 | 1 |
+++++++++++++++++++++++++++++
+ cat | 1 | 2 |
+++++++++++++++++++++++++++++
+ tag | 1 | 2 |
+++++++++++++++++++++++++++++
I want to get posts with its cats and tags
what’s the best way to do this
The only way i know now
is get posts then foreach post get its cats and tags
See it on sqlfiddle.