Update one row per user
Posted: Tue Jun 24, 2008 8:24 am
A user may have many records in a table. What I want to do is increment a column in the table for each users first row--I do not want to update every single row.
Imagine this was the table:
For this, I would only want to update rows 1, 2 and 3. I assume I would need a group by of some sort, but after that I am kinda lost.
Imagine this was the table:
Code: Select all
row_id | user_id | count
---------+-------------+----------
1 | 1 | 10
2 | 2 | 5
3 | 3 | 2
4 | 1 | 4
5 | 1 | 6
6 | 2 | 1