|
![](/images/resource/spacer.gif) |
|
อยากทราบวิธีการ query ให้ผลลัพธ์ออกมาเป็นกลุ่ม และหาจำนวนของข้อมูลที่เหมือนกัน |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (PHP)
$db=new mysqli('localhost', 'test', 'test', 'test');
$rs = $db->query('select tistinct brand from table');
$g='';
while ($ro=$rs->fetch_assoc()) $g.= $g . ", sum( brand = '$ro[brand]') $ro[brand]";
$rs = $db->query( "select province $g from table group by province");
while ($ro=$rs->fetch_assoc()) echo '<pre>', print_r($ro, true), '</pre>';
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2015-09-07 07:46:15 |
By :
NewbiePHP |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 02
|