【发布时间】:2014-09-27 18:38:40
【问题描述】:
我有一个查询,我要加入两个查询以获得我想要的,我可以在 SQL 中很好地管理它,但是我现在完全不知道如何为 Laravel 编写这个。这是 SQL:
select *
from
(
select stu.s_nid as student_nid, stu.name as student_name, vote.id as vote_id
from student stu
left join vote on vote.student_id = stu.id
where vote.vote_no != 0
) as q1
inner join
(
select stu.s_nid as nominee_nid, stu.name as nominee_name, vnd.nominee_type_id, vnd.vote_id, nt.name_ar
from vote_nominee_details vnd
left join nominee nom
on nom.id = vnd.nominee_id
left join student stu
on stu.id = nom.student_id
left join vote
on vote.id = vnd.vote_id
left join nominee_type nt
on nt.id = vnd.nominee_type_id
where vnd.vote_id is not null
and vote.vote_no != 0
) as q2 on q1.vote_id = q2.vote_id
任何帮助将不胜感激
【问题讨论】:
标签: php mysql laravel laravel-4