Good afternoon community. I am a beginner in this of the stored procedures, and I would like to know some way to do the following:
I have these 2 tables:
Balances
saldoid|cuentaid|deudas|abonos|mes
-------+--------+------+------+---
1 | 1 | 2000 | 1000 | 1
2 | 2 | 3000 | 100 | 1
3 | 5 | 100 | 50 | 1
4 | 3 | 200 | 120 | 2
5 | 6 | 40 | 40 | 2
6 | 4 | 2304 | 2100 | 3
Accounts
cuentaid|cuenta |deudas01|abonos01|deudas02|abonos02|deudas03|haber03
--------+-------+--------+--------+--------+--------+--------+--------
1 |1020319| 2000 | 1000 | 0 | 0 | 0 | 0
2 |1823934| 3000 | 100 | 0 | 0 | 0 | 0
3 |1238923| 100 | 50 | 0 | 0 | 0 | 0
4 |2389235| 0 | 0 | 200 | 120 | 0 | 0
5 |9583313| 0 | 0 | 40 | 40 | 0 | 0
6 |1223940| 0 | 0 | 0 | 0 | 2304 | 0
What I need to do is a stored procedure, which takes a tour of the table of accounts, to get all the accounts.account , and followed by this, add debts / credits for balances .county .
NOTE: I already have part of the stored procedure, I would like to know how to do the tour and add cuenta.cuentaid .