左连接 前几行

左连接:在等值连接的基础上把左边未匹配到等值的也显示出来

左连接:left join

age:

select
             n.*,
             u.*,
             r.*,
             c.name categoryName,
             u1.nickname checkUsersName
        from n_news n inner join n_users u on n.users_id = u.id
                      inner join n_category c on n.category_id = c.id
                      inner join n_users u1 on n.check_users_id = u1.id
                      left join n_replys r on r.news_id = n.id
        where n.id = #{id}
                order by r.id desc
                limit 0,2

 

搜索前两行:

使用limit限制:limit 0,2

 

posted @ 2020-06-08 11:00  云山有相逢  阅读(112)  评论(0)    收藏  举报