I’m trying to join 3 tables, somehow do an hierarchical inner join, and get data from the 3rd table. My starting point is the article_number (156118) from the article table. Here are the working sql statements and table structure, but there must be a way to join all this together in one, right?
// Get the parent task from the article
select task_parent
from article a, tasks t
where a.task_id = t.task_id
and a.article_number = 156118
// Get the task id for the 'Blog' task
select task_id
from tasks
where task_parent = 26093
and task_name like '%blog%'
// Get ALL the blog record
select *
from blogs
where task_id = 26091
---------Tables------------
* article table *
id | article_number | task_id
1 | 156118 | 26089
* tasks table *
id | task_name | task_parent
26089 | article | 26093
26091 | blogs | 26093
26093 | Main Task | 26093
* blog table *
id | task_id | content
1 | 102 | blah
2 | 102 | blah
3 | 102 | blah
-------------
* How do I get all of blog data with 1 SQl statement using just the article_number?
Thanks in advance!
EDIT: Revised answer after rereading question. You need two joins to the task table. One to get the parent of the article’s task and a second to get the blog task with the same parent as the article’s task.