求一条SQL
mysql数据库
问题表(question),回答表(answer)他们里面都有一个time列,要找出问题表中的数据和回答表只“最新”回复的数据,并且按两个表的时间排序。补充一下,只要回答表最新的回复,别的过滤掉,另外,问题可能没有回答。对应字段是回答表里有其回答问题的ID
如question表 answer表
question_id question_time 丨 answer_id answer_time answer_questionid
1 2010-03-21 13:46:42 丨 1 2010-03-21 13:49:42 1
2 2010-03-21 13:48:42 丨 2 2010-03-21 13:52:42 1
3 2010-03-21 13:58:42 丨 3 2010-03-21 13:49:49 2
4 2010-03-21 13:60:42 丨
我要的结果是
question_id question_time answer_id answer_time answer_questionid
4 2010-03-21 13:60:42
3 2010-03-21 13:58:42
1 2010-03-21 13:46:42 2 2010-03-21 13:52:42 1
2 2010-03-21 13:48:42 3 2010-03-21 13:49:49 2
因为2010-03-21 13:60:42>2010-03-21 13:58:42>2010-03-21 13:52:42>2010-03-21 13:49:49