TP5's connected table query plus calculation total

$list=Db::name("storage_name")
            ->alias('a')
            ->join('storage b','a.name=b.storage_name')
            ->field(['a.id,a.name,sum(b.number) as count'])
            ->group('a.name')
            ->paginate(15);

alias is equivalent to as in sql

The filed here can be spelled directly using the sql statement

group grouping

pageinate pagination.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325061677&siteId=291194637