要实现论坛回复一个帖子后(也就是顶帖)帖子自动靠前其中表A 为主题表,有id, 文章标题title,和内容content等字段
表B为针对表A的回复内容表,有id,art_id, 文章标题title,和内容content等字段,用art_id字段关联表A的id请高手帮忙,要实现论坛回复一个帖子后(也就是顶帖)帖子自动靠前,读出主题帖子,如何写sql语句阿?

解决方案 »

  1.   

    回复内容表id  ORDER BY id DESC  ?
      

  2.   

    其中表A 为主题表,有id, 文章标题title,和内容content等字段
    表B为针对表A的回复内容表,有id,art_id, 文章标题title,和内容content等字段,用art_id字段关联表A的idselect a.* , b.* from a,b
    where a.id = b.art_id
    order by b.id desc
      

  3.   


    select a.id,a.title,a.content,b.title,b. from a,b.content
    from a left jion b on a.id = b.art_id
    order by b.id desc
      

  4.   

    select a.id,a.title,a.content,b.title,b.content
    from a left jion b on a.id = b.art_id
    order by b.id desc????
      

  5.   

    select b.art_id as id , b.文章标题title , b.内容content from b order by id desc
    union all
    select * from a where id not in (select art_id as id from b)