php - Mysql count totals multiple items by condition left join -
i trying wrap head around how achieve following without writing 5 or more database queries , 10 if statements each
i have red, blue , green widgets rated 1-10 how display how many of each in database? ie
red widgets:
- 6 rated 1
- 12 rated 2
- 30 rated 3
etc
and same blue , green well?
$sql = "select unit.type, unit.condition, count(1) count left join units on site.id=unit.id site.name='name' group unit.type, unit.condition";
Comments
Post a Comment