As I fixed the previous question thanks to the answer, I am sticking now in the part to retrieve a thread based on the last thread_date.
The code itself seems to be working fine, but it is only printing one result out instead of others.
The thread has a threads.cat_id which is linked to thesubsubcategory.extra_cat_id.
SELECT
parent.subcat_id,
parent.subcat_name,
child.subsubcat_name,
child.subcat_id,
child.cat_id,
kid.thread_name,
kid.cat_id,
kid.thread_date
FROM
subcategories parent
JOIN subsubcategories child
ON child.cat_id = parent.cat_id
JOIN threads kid ON child.extra_cat_id = kid.cat_id
WHERE thread_date = (SELECT MAX(thread_date) FROM threads)
What I am expecting is this:
Category
Subcategory Latest thread
Subcategory Latest thread
What I am getting is this:
Category
Subcategory Latest thread
SQL fiddle: http://sqlfiddle.com/#!9/52e27/2
Any solutions to it?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…