有人可以帮我把这个mysql查询转换成redbean查询吗?
SELECT category,sum(price) from transaction GROUP BY category.
答案 0 :(得分:3)
我们可以使用
$results = R::getAll( 'SELECT category,sum(price) from transaction GROUP BY category' );
// $results is multidimensional array
答案 1 :(得分:0)
您无需转换任何内容。你只需写:
$transactions = R::get("SELECT category,sum(price) from transaction GROUP BY category");
答案 2 :(得分:0)
更好的转换是:
$ sql =“SELECT类别,总和(价格)FROM交易GROUP BY类别”;
$ transactions = R :: getAll($ sql);