Reputation: 313
I need to retrieve distinct records from a column in a mysql table and then retrieve data from each row that the distinct records show up in. Sorry if this isn't very clear. I can elaborate if necessary.
EDIT:
+------+------+-----+
| ip | hits | day |
+------+------+-----+
| ip1 | 23 | 52 |
+------+------+-----+
| ip2 | 28 | 50 |
+------+------+-----+
| ip1 | 46 | 54 |
+------+------+-----+
| ip4 | 15 | 55 |
+------+------+-----+
| ip2 | 12 | 52 |
+------+------+-----+
I need to select distinct ips, then for each ip add up all the hits for that ip.
Upvotes: 1
Views: 253
Reputation: 20004
It doesn't sound like you need two queries, you just need to select distinct rows for the first column and then use a where clause for the additional data.
Upvotes: 0