1
請我怎麼知道的次數大衛的2我怎麼知道一個值出現在mysqli的選擇的次數
投票Name | Vote
-------------
|Gabri| 2
|David| 2
|Janny| 3
|David| 1
|David| 2
|Fally| 3
請我怎麼知道的次數大衛的2我怎麼知道一個值出現在mysqli的選擇的次數
投票Name | Vote
-------------
|Gabri| 2
|David| 2
|Janny| 3
|David| 1
|David| 2
|Fally| 3
$sql = "SELECT count(*) from table_name WHERE Name= 'David' and Vote=2";
$result = mysqli_query($con, $sql);
$fetch = mysqli_fetch_assoc($result);
echo "<pre>";
print_r($fetch);
echo "<pre>";
輸出
Array
(
[count(*)] => 4
)
以獲得您需要的值echo $fetch['count(*)']; //outputs 4
select Name , count(Name) where Name = 'David' group by Name having count(Name) =2
'select count(*)fr om thetable where Name =「David」and Vote = 2' – splash58
http://dev.mysql.com/doc/refman/5.7/en/group-by-functions.html –
好的,謝謝你的回覆,但我該如何返回如果找到了投票的價值 –