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;



你可能感兴趣的:(php,ThinkPHP)