<?php
$query = mysql_query("SELECT DISTINCT Count(tbl_brandname.brandname_id) AS `Sum`, tbl_brandname.name FROM tbl_brandname Inner Join tbl_product ON tbl_brandname.brandname_id = tbl_product.brandname_id GROUP BY tbl_product.brandname_id, tbl_brandname.name");
while( $row = mysql_fetch_array($query) ){
echo $row[tbl_brandname.name]."--''.$row[Sum]."<br>";
?>
Date :
2009-06-08 16:05:05
By :
nongjen
No. 6
Guest
------SQL Server นะครับ ลองดู
select count(n.brandname),n.name
from tbl_brandname as n
inner join
tbl_product as p
on n.brandname = p.brandname_id
group by sum(n.brandname),n.name
having count(*) > 1
Date :
2009-07-26 22:48:18
By :
Guriko10
No. 7
Guest
ลองดูแบบนี้
Select a.brandname_id,a.name,count(*) as CNT
from tbl_brandname a
inner join tbl_product b
on a.brandname_id = b.brandname_id
group by a.brandname_id,a.name
Select a.brandname_id,a.name,count(*) as CNT
from tbl_brandname a
inner join tbl_product b
on a.brandname_id = b.brandname_id
group by a.brandname_id,a.name