Thinkphp LEFT JOIN
2022-11-24 11:10:29
211
{{single.collect_count}}

Thinkphp3.2.3 解决其中一表为空而不显示内容办法 

$list = M('Company')
                 ->alias('a')
                 ->join('LEFT JOIN wp_company_items i on a.items_id = i.id')
                 ->join('LEFT JOIN  wp_ginseng_result r on a.id = r.order_id')
                 ->field('a.*,i.items_title,r.gin_num')
                 ->order('a.id desc')
                 ->where($where)
                 ->select();

 

  • INNER JOIN: 等同于 JOIN(默认的JOIN类型),如果表中有至少一个匹配,则返回行
  • LEFT JOIN: 即使右表中没有匹配,也从左表返回所有的行
  • RIGHT JOIN: 即使左表中没有匹配,也从右表返回所有的行
  • FULL JOIN: 只要其中一个表中存在匹配,就返回行
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}