我有GET印象兩個表,並加入點擊MYSQL - 得到INNER數據有兩個表
Product
+----+--------+
| PID| brand |
+----+--------+
| 1 | Ford |
| 2 | Toyota |
| 6 | Holden |
+----+--------+
States
+----+--------+------+--------+------------+
| ID | PID |CLICKS| VIEWS | DATE |
+----+--------+------+--------+------------+
| 1 | 1 | 1 | 0 | 12/12/2015|
| 1 | 1 | 1 | 0 | 12/12/2015|
| 2 | 2 | 1 | 0 | 12/12/2015|
| 3 | 2 | 0 | 1 | 12/12/2015|
| 3 | 1 | 0 | 1 | 12/12/2015|
+----+--------+------+--------+------------+
我需要這樣的
+--------+------+--------+
| PID |CLICKS| VIEWS |
+--------+------+--------+
| 1 | 2 | 1 |
| 2 | 1 | 0 |
+--------+------+--------+
一些結果是這可能嗎?我已經嘗試過很多次了未來的故障數據
使用GROUP BY進行聯接。 – jarlh
查找「group by」工作方式 –
'SELECT stats_property.date,property.idproperty,COUNT(stats_property.clicks ='1')AS A,COUNT(stats_property.impression ='0')AS I FROM屬性INNER JOIN stats_property ON property.idproperty = stats_property.idproperty group by property.idproperty,stats_property.clicks'我試試這種方式不起作用 – user1750832