I'm having trouble selecting a random row from an sqlite database, this works to select all rows meeting a criteria:
tx.executeSql('SELECT * FROM games WHERE genre="fps" AND decade=90', [], renderResultsTest);
If I then try to retrieve just one of these randomly it wont work:
tx.executeSql('SELECT * FROM games WHERE genre="fps" AND decade=90 ORDER BY RANDOM() LIMIT 1', [], renderResultsTest);
I have a workaround where I use the first statement and loop through the results putting the row ID's into an array and then select a random ID from the array. This works fine but I'd prefer to do it directly in one statement.
I've seen this question asked before on here and googled it myself but it seems the order by random and limit to one result should work, is my syntax wrong or something else causing the problem?
Any advice would be most welcome,
Thanks