SELECt
qst_id,qst_title,ans_date,ans_text
FROM
(
SELECT
a.Question_Id as qst_id,a.Question_Title as qst_title,a.Question_Text as qst_text,DATE_FORMAT(a.LastActivity_Date,'%d %b %Y %T') as qst_date,b.UserForum_Image as qst_prof,b.ScreenName as qst_scname
FROM
tblforumquestion a, tblregistration2_2 b
WHERE a.RegistrationId=b.RegistrationId and a.LastActivity_Date between '2014-0-01 00:00:00' and '2015-05-01 00:00:00'
ORDER BY a.LastActivity_Date desc limit 5
outer join
SELECT
DATE_FORMAT(c.Answer_Date,'%d %b %Y %T') as ans_date,c.Answer_Text as ans_text,d.UserForum_Image as ans_prof,d.ScreenName as ans_scname
FROM
tblforumanswer c ,tblregistration2_2 d
where c.Answer_Id in
(
SELECT MAX(Answer_Id)
FROM tblforumanswer
GROUP BY Question_Id
)
and c.RegistrationId=d.RegistrationId
order by c.Answer_Date desc limit 5
)
I am trying to get latest 5 question and answers from my post.if any question without answer is there,it should also display as question details in one row with null answer details.But the above code is getting error.Any help is appreciable.my database is mysql.
tblquest tblans result