aaronk Well-Known Member Licensed User Longtime User Jun 16, 2013 #1 Hello, I have a SQL database and I am trying to view the data that is stored in it. Is there a way to select a record without knowing what is stored in that recorded? I am normally using the following code to select a item but I want to be able to select a record without know what the id is: Code: Copy SQL1.ExecQuerySingleResult("SELECT device_name FROM settings WHERE id = 2" For Example, I have 20 records in my database and I want to select the 4th one in the list without using the id number. Or is there a way to add a autoincrement primary key to each record that will be unique for all records? Last edited: Jun 16, 2013
Hello, I have a SQL database and I am trying to view the data that is stored in it. Is there a way to select a record without knowing what is stored in that recorded? I am normally using the following code to select a item but I want to be able to select a record without know what the id is: Code: Copy SQL1.ExecQuerySingleResult("SELECT device_name FROM settings WHERE id = 2" For Example, I have 20 records in my database and I want to select the 4th one in the list without using the id number. Or is there a way to add a autoincrement primary key to each record that will be unique for all records?
Erel B4X founder Staff member Licensed User Longtime User Jun 16, 2013 #2 Auto increment is explained here: SQLite Autoincrement You can fetch all items (easier with DBUtils.ExecuteMemoryTable) and then take the one you need. Upvote 0
Auto increment is explained here: SQLite Autoincrement You can fetch all items (easier with DBUtils.ExecuteMemoryTable) and then take the one you need.
aaronk Well-Known Member Licensed User Longtime User Jun 16, 2013 #3 Thanks Erel. Got it working by using: Code: Copy SQL1.ExecNonQuery("CREATE TABLE settings(id INTEGER PRIMARY KEY, device_name TEXT)") Now each record has a unique key making it easy to select the item. Upvote 0
Thanks Erel. Got it working by using: Code: Copy SQL1.ExecNonQuery("CREATE TABLE settings(id INTEGER PRIMARY KEY, device_name TEXT)") Now each record has a unique key making it easy to select the item.