java - Read next or previous mysql rows and update current row without using cursors or auto-incremented value -
I need to record some records that are in a mysql table. The problem is that incrementable id is not a trusted way to know
id, number, status
P> .
I want to read number one at a time and every time I want to read the next or the last, then I have no problem getting it from the database. Once I get the number, I want to double it and type the position of the column.
The cursor will be useful, but the cursor will not allow me to read the underlying table which I am reading. Is there a solution that can allow me to read the next and previous values and at the same time allow me to update the current line?
Thank you.
I am not saying that this is the best way, however, can be: < / P>
$ rows = SELECT id FROM & lt; Table & gt; Forex currency ($ lines as $ line) {$ prev = SELECT number FROM < Table & gt; WHERE id & lt; $ Line ORDER id from DESC border 1; $ Next = SELECT number to & lt; Table & gt; WHERE id & gt; $ Line ORDER id ASC limit1; If updated ($ pre & amp; $ next) & lt; Table & gt; SET = 2 ($ prev + $ next) WHERE id = $ row; }
OK, similar object can be obtained through the cursor.
Comments
Post a Comment