我正在努力使用 Laravel Query Builder 构建以下嵌套的复杂查询。我正在使用 laravel 4.0。嵌套连接的主要问题。
SELECT clubs.id, clubs.slug, clubs.name as `club_name`, clubs.state, clubs.category, clubs.live, `m`.`total_members`, `m`.`online_members`, `m`.`offline_members`, `m`.`last_7days_members` as `total_members_last_7days`
FROM clubs
LEFT JOIN
(
SELECT id, club_id, count(*) as `total_members`, SUM(online_member = 1) AS online_member
FROM members
LEFT JOIN
(
SELECT posts.id, posts.member_id, posts.title, posts.body
FROM posts
WHERE posts.transaction_id IS NOT NULL
) p on p.member_id = members.id
WHERE (`post_verfied` is null or `post_verfied` = 1)
AND `members`.`deleted_at` is null
group by club_id
) m on m.club_id = clubs.id
LEFT JOIN comments on comments.member_id = m.id
WHERE clubs.`deleted_at` is null
group by `clubs`.name
请帮忙..