I am trying to join 3 tables, somehow make a hierarchical inner join and get data from the third table. My starting point is the article number (156118) from the article table. Here are the working sql statements and the table structure, but there should be a way to combine 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
* 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 to get all blog data using 1 SQl statement using only article_number?
Thanks in advance!
source
share