首頁  >  文章  >  php框架  >  Thinkphp使用join聯表查詢的方法

Thinkphp使用join聯表查詢的方法

angryTom
angryTom轉載
2020-03-24 11:57:434411瀏覽

這篇文章介紹了Thinkphp使用join聯表查詢的方法,具有一定的參考價值,希望對各位學習thinkphp的朋友有幫助!

Thinkphp使用join聯表查詢的方法

Thinkphp使用join聯表查詢的方法

多重資料表聯查:

$user = M('user');
$b_user = M('b_user');
$c_user = M('c_user');
$list = $user->alias('user')->where('user.user_type=1')
    ->join('b_user as b on b.b_userid = user.user_id')
    ->join('c_user as c on c.c_userid = b.b_userid')
    ->order('b.user_time')
    ->select();

$user 表的user_id 等於$b_user表的b_userid; 

$c_user表的c_userid 等於$b_user表的b_userid;

推薦學習:thinkphp教學

教學#######建議學習:###thinkphp教學######教學

以上是Thinkphp使用join聯表查詢的方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除