将mysql查询转换为laravel样式

apeeds0o  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(187)

如何将此查询转换为laravel样式

SELECT 
    gr.name,
    p.ma_status AS status,
    COUNT(p.ma_status) AS total
FROM accounts u
LEFT JOIN accounts_prop p ON p.account_id = u.account_id 
AND ( 
       SELECT j.iid
       FROM accounts_prop AS j  
       WHERE u.account_id = j.account_id 
       AND j.ma_status IS NOT NULL
       ORDER BY j.von DESC  LIMIT 1 
) = p.iid
LEFT JOIN `deprecators` gr ON gr.id = p.group_id 
LEFT JOIN `deprecators` unit ON unit.id = p.unit_id 
LEFT JOIN `deprecators` team ON team.id = p.team_id 
WHERE p.group_id IS NOT NULL
AND u.account_status = 'A'
GROUP BY p.ma_status, gr.id

我不知道我该如何接受下面的陈述

LEFT JOIN accounts_prop p ON p.account_id = u.account_id 
AND ( 
       SELECT j.iid
       FROM accounts_prop AS j  
       WHERE u.account_id = j.account_id 
       AND j.ma_status IS NOT NULL
       ORDER BY j.von DESC  LIMIT 1 
) = p.iid

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题