Slt. a tous.
ce que je voudrais savoir, c´est s´il existe quelque chose du genre:
Ma_table
(ID_MA_table,tdoc,ndoc,nom)
je m´exlique:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 insert into Ma_table (tdoc,ndoc,nom) values (2,select max(ndoc)+1 from Ma_table where tdoc=2,"XXX")
je voudrais que ndoc soit un compteur de document, en funtion du tdoc( type du doc)
1 | 2 | 1 | XXXX
2 | 2 | 2 | YYY
3 | 1 | 1 | hhh
pour l´instant j´ai:
mais je trouve qu´il doit avoir plus facile, vue que ce probleme doit arriver a
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 start transaction; lock table Ma_table write; SELECT @A:=max(codigo)+1 from MA_table where tdoc =2; insert into Ma_table (tdoc,ndoc,nom) values (2,@A,"XXX"); unlock tables; commit;
presque tous le monde... si quelqun me peut donner des idees...
merci...
Partager