您的位置 首页 php

Thinkphp使用join联表查询的方法

本篇文章介绍了Thinkphp使用join联表查询的方法,具有一定的参考价值,希望对各位学习thinkphp的朋友有帮助!

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使用join联表查询的方法

文章地址:https://www.zhihuclub.com/27995.shtml

关于作者: 智云科技

热门文章

网站地图