In article <[EMAIL PROTECTED]>, "Dan Tappin" <[EMAIL PROTECTED]> writes:
> Actually it's not a total and can't be calculated. > The idea is that as users (with individual id_client keys) add rows the id of the > row is auto incremented for their key only. > Example: > If user A adds 3 rows: > id id_client > --------------- > 1 A > 2 A > 3 A > and then user B adds 2 rows > id id_client > --------------- > 1 A > 2 A > 3 A > 1 B > 2 B > I am not looking for a sum of each client's records... that's an easy query... I > need the auto incremental id's for each client. Let's add an ordinary auto_increment column named "ser" (for serial): ser id_client id 1 A 1 2 A 2 3 A 3 4 B 1 5 B 2 Now the query SELECT t1.ser, t1.id, count(t2.id) + 1 AS calc_id FROM tbl t1 LEFT JOIN tbl t2 ON t2.ser < t1.ser AND t2.id_client = t1.id_client GROUP BY t1.ser, t1.id shows you that calc_id = id for all rows, which means that id can be calculated. The only difference is when you delete rows inbetween. In this case id_calc will be less than id. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]