龍巖易富通網(wǎng)絡科技有限公司

龍巖小程序開發(fā),龍巖分銷系統(tǒng)

thinkphp left join查詢

2015.09.10 | 796閱讀 | 0條評論 | php

一個表xpf_categories??一個表xpf_log 原生態(tài)sql: select?xpf_categories.*,count(xpf_log.categoryid)?as?num?from?xpf_categories?left?join?xpf_log?on?xpf_categories.id=xpf_log.categoryid?group?by?xpf_categories.id;   thinkphp?下: $categories=M("Categories"); $category=$categories->table('xpf_categories')->join('xpf_log?on?xpf_categories.id=xpf_log.categoryid')->field('xpf_categories.*,count(xpf_log.categoryid)?as?artnum')->group('xpf_log.categoryid')->select();

贊 (

發(fā)表評論