SELECT
`sp`.name_en,
`sp`.email,
`sp`.phone,
`post`.`name`
AS
`position_name`
FROM
`staff_profiles` `sp`
INNER JOIN
`staff_positions` `p`
INNER JOIN
`positions` `post`
WHERE
`sp`.id=`p`.`staff_id` AND `p`.`position_id`=`post`.id
答案 0 :(得分:2)
您可以使用查询生成器构建相同的查询: https://laravel.com/docs/5.4/queries
或者您可以使用DB
Facade运行原始查询:
https://laravel.com/docs/5.4/database#running-queries
这样的事情:
DB::select('SELECT sp.name_en, sp.email, sp.phone, post.name AS position_name FROM staff_profiles sp INNER JOIN staff_positions p INNER JOIN positions post WHERE sp.id=p.staff_id and p.position_id=post.id');
答案 1 :(得分:0)
包括您使用BusinessObject \ User的模型;以下查询是示例查询。
$matchThese = ["job_comments.status" =>1,'job_id'=>$job_id];
$job_com = DB::table('job_comments')
->select('job_comments.*','users.id as userid','users.first_name','users.last_name','users.image','users.role')
->where($matchThese)
->join('users', 'job_comments.commenter_id', '=','users.id' )
->get();