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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -