I have a table of Chamados
. I have to add an entire column that will be called sequencia
and it will be used to search the order that the user wants.
Just to illustrate: the call will have arrows, when you click the arrow pointing up, this call will increase the number of the column sequencia
, and change all other records so that the call is above what was above. Same thing if you click the down arrow, changing its order, remembering that the sequence column can not have repeated numbers.
Can anyone help? I'm developing in JAVA
and MySQL
.
EDIT:
Based on the comments, I decided to do so:
UPDATE chamado SET sequencia = sequencia + 1 WHERE cod = 1
UPDATE chamado SET sequencia = sequencia - 1 WHERE cod = 2
So it increases the value of the sequence where the user clicked, in case the code 1, and decreases the value of the code above so that code 1 has a value more auto than code 2, to do the opposite: / p>
UPDATE chamado SET sequencia = sequencia - 1 WHERE cod = 1
UPDATE chamado SET sequencia = sequencia + 1 WHERE cod = 2