I have a table called Post:
title (NULL), content, parent_id (NULL)
The title is null because I use this for threads and replies (replies do not have a title and threads do not have a parent).
Say I want to select all the replies to post x, or an n number of replies:
SELECT * FROM post
WHERE title IS NULL
AND parent_id = x
or,
SELECT * FROM post
WHERE title IS NULL
AND parent_id IS NOT NULL
LIMIT 0, 30
How can I also select the title of a reply? Say for example if I select reply number 5 and it's a reply to post id# 2 (i.e has parent_id of 2), how can I select the title of number 2?
I don't want to use a foreach loop in mysql.
Hope this makes sense.
Thank you.