我有一个mysql查询
SELECT a.`head_id` AS "Headid",a.`name` AS "HeadName", b.`id` AS "Emp_ID",b.`name` AS "Emp_name" FROM users a join users b ON a.id=b.head_id where a.`head_id`=63 or b.`id`=63
如何将此查询转换为laravel?
$users = DB::table('users a')
->join('users b', 'a.id', '=', 'b.head_id')
->select('a.head_id as Headid','a.name AS HeadName','b.name AS Emp_name','b.name AS Emp_name')
->get();
但不幸的是这不起作用。请帮帮我。
1条答案
按热度按时间kg7wmglp1#
您的查询生成器看起来不错,只需根据您的普通查询添加where过滤器即可