laravel 这个同样两张表取别名查询出错,怎么改呢
1个回答
2016-09-09
展开全部
$res = DB::table('topics')->select('topics.*', 'b.username',
'b.avatar', 'c.username as rname', 'd.cname')
->where('topics.is_hidden', 0)
->leftJoin('users AS b', 'b.uid', '=', 'topics.uid')
->leftJoin('users AS c', 'c.uid', '=', 'topics.ruid')
->leftJoin('nodes AS d', 'd.node_id', '=', 'topics.node_id')
->orderBy('ord', 'desc')
->take($limit)->get();
'b.avatar', 'c.username as rname', 'd.cname')
->where('topics.is_hidden', 0)
->leftJoin('users AS b', 'b.uid', '=', 'topics.uid')
->leftJoin('users AS c', 'c.uid', '=', 'topics.ruid')
->leftJoin('nodes AS d', 'd.node_id', '=', 'topics.node_id')
->orderBy('ord', 'desc')
->take($limit)->get();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询