Laravel Query Builder原始表达式

时间:2016-12-10 11:43:38

标签: php mysql laravel laravel-5

如何使用查询构建器在(temp = str[i])子句中编写原始表达式?

join

我尝试过以下方式实现它,但它不起作用:

SELECT 
    rating.post_id,
    sum(rate_like), 
    sum(rate_dislike), 
    (sum(rate_like) + sum(rate_dislike)),
    column_rating
from rating
inner join (
    select 
        post_id, 
        round(round((((sum(rate_like) / (sum(rate_like) + sum(rate_dislike)) * 100) * 0.5) / 10) * 2) / 2, 1) as column_rating
    from rating group by post_id
) as rating_table
on rating.post_id = rating_table.post_id
group by rating.post_id

1 个答案:

答案 0 :(得分:0)

我能够使用->join(DB()->raw('select...')

成功查询它