如何在 Laravel、子查询中执行此操作
How to do this in Laravel, subquery
How can I make this query in Laravel:
select users.username,users.photo, questions.*,
(Select count(*) from answers
where answers.q_id=questions.id) as aAccount from questions
INNER JOIN users ON users.id=questions.user_id
您可以对所有查询使用 db raw 或 DB::connection()->select()->join()->join()->query('subqueryz') ->where()->orderBy()
第二个选项最好。
How can I make this query in Laravel:
select users.username,users.photo, questions.*,
(Select count(*) from answers
where answers.q_id=questions.id) as aAccount from questions
INNER JOIN users ON users.id=questions.user_id
您可以对所有查询使用 db raw 或 DB::connection()->select()->join()->join()->query('subqueryz') ->where()->orderBy()
第二个选项最好。