skysigma
Posts: 24
|
Posted: 09/28/2014, 6:02 PM |
|
Hi there
I have a situation like that:
id_1 | id_2
------------------
1 | 1
1 | 2
1 | 3
2 | 1
3 | 1
3 | 2
How can auto-increment the value of the id_2 based on the value of id_1?
Thanks
Marco
|
|
|
jekes
Posts: 36
|
Posted: 09/29/2014, 2:56 AM |
|
Hi,
You can do this with the query SELECT id_1 + n AS id_2
Or in the BeforeShow Row event you can retrieve the value of id_1 and change the value of the id_2 with the new one.
|
|
|
skysigma
Posts: 24
|
Posted: 09/29/2014, 12:02 PM |
|
I used the following trigger
BEGIN
DECLARE counter INT;
SELECT COALESCE(MAX(id_2),0)+1
INTO counter FROM table WHERE id_1 = NEW.id_1;
SET NEW.id_2=counter;
END
|
|
|
|