Afternoon,
I’m really struggling to get my head around using sqlite with Corona and am hoping for a bit of insight.
I’m in the process of creating a trivia app and have a bank of questions in sqlite - as a basic first step I was hoping to choose a random row from the database to present the question, but whatever I try just returns errors. I’ve just started learning to code this year, so apologies if it’s something obvious.
The code I’ve started with is this:
– load a question from sqlite
for row in db:nrows(“SELECT * FROM ‘bank1’ LIMIT 1”) do
local questiontext= row.question…" "
local qt = display.newText(questiontext, display.contentCenterX, 100, native.systemFont, 14)
qt:setTextColor(1,1,1)
end
which does as expected, from what I’ve read if I add the below it should randomise the data, however this doesn’t seem to be working?
for row in db:nrows(“SELECT * FROM ‘bank1’ ORDER BY RANDOM() LIMIT 1”) do
My database is simply a question per row and then 3 possible answers in the adjacent columns.
Thank you