在三个不同的文章表中查询最后发布的一篇文章,并显示标题,请问如何查询?

1.三个文章详情表 加上一个用户表,找出最近时间发布的一篇文章并显示其详情
2.现在我的做法是
select (SELECT time from g_answer where uid=m.id and a_status=1 order by time limit 1) answer,(SELECT time from g_enjoy where uid=m.id and e_status=1 order by time limit 1) enjoy,(select time from g_art_detail where user_number=m.id and status=1 ORDER BY time LIMIT 1) article from g_member m where id=13975;
3.然后进行时间排序,返回键名,然后根据具体表再次查询具体信息。
总感觉麻烦,有没有优化的方式?

阅读 2.1k
1 个回答

建议在向三个文章表插入数据时,新建一张表(id,article_table,art_id) 专门存储这三个表中最新的那条记录,然后查的时候就方便多了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题