0
|like |comment|
|user1|asd |
|user2|awe |
|user3|aqw |
|user4|atr |
|user5|axc |
|user6|azw |
|user7| |
我有两个列,我想要做的就是总结这些列中的所有行和取两列,但我没有任何想法如何在SQL查询中做到这一点。
结果
|like |comment|
| 7 | 6 |
我尝试queering,但我只能取1列,我不知道如何与两个列做..
function countpostcomment($puid){
$sql = "SELECT COUNT(pc_comment) FROM pcomment WHERE post_uid = '$puid'";
$stmt = $this->dbh->prepare($sql);
$stmt->execute(array("0"));
$active_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
return $active_data;
}
这里是我的示例查询我没有测试过整个功能只有选择原因我不知道我是否需要使用阵列或不..
如果这工作我需要使用数组来获取数据或不? –
@AlfieGaring。 。 。这返回一列两列。一个数组看起来像是矫枉过正。 –