Yii数据库子查询嵌入select中,而不是where条件语句中

$subQuery = (new Query())->select('COUNT(*)')->from('user');

// SELECT `id`, (SELECT COUNT(*) FROM `user`) AS `count` FROM `post`
$query = (new Query())->select(['id', 'count' => $subQuery])->from('post');

不太懂'count' => $subQuery插入的意思。
posted @ 2017-02-08 01:16  jerryhe326  阅读(2411)  评论(0编辑  收藏  举报