Android Question SQLite set rowid new on a order by command

Alexander Stolte

Expert
Licensed User
Hello,

Because i work with the ROWID, is this a issue if the data change to a newer value and nothing happend, when i load all components new.

This does not work.
B4X:
SQL1.ExecQuery("SELECT column1, column2 FROM table1 WHERE rowid=" & (i +1) & " ORDER BY time DESC")

Is there a way to reorder the rowid so that the newest time gets rowid 1?

if come a newer time from the database, i just update the row and reload new.

Greetings
 

klaus

Expert
Licensed User
Longtime User
Is there a way to reorder the rowid so that the newest time gets rowid 1?
No, you cannot.
Every time you add a new record rowid is incremented by one.
If you delete records, their rowids are lost all the other remain.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
I always use primary keys that autoincrement
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
In SQLite, a column with type INTEGER PRIMARY KEY is an alias for the ROWID (except in WITHOUT ROWID tables) which is always a 64-bit signed integer.

rowid can not be changed as already answered by klaus.
 
Upvote 0

OliverA

Expert
Licensed User
Hello,

Because i work with the ROWID, is this a issue if the data change to a newer value and nothing happend, when i load all components new.

This does not work.
B4X:
SQL1.ExecQuery("SELECT column1, column2 FROM table1 WHERE rowid=" & (i +1) & " ORDER BY time DESC")
What are you trying to accomplish? Since you include rowid in your query with an equals comparison operator, this will return either one or zero results (one if the rowid exists and zero if not). So why the need for ORDER BY? Again, what are you trying to accomplish?
 
Upvote 0
Top