B4J Question Retrieval from MySQL database with a Random requirement

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All,

I have not attempted to do this line of code yet as I am not a Wizz at SQL or B4J so I was hoping someone could give me a starting point or a direction I should be going in or even if this is possible.

I do not want to retrieve all the results and then randomise between those, that would be easier but would take time to remotely retrieve the database.

There are 3 fields that are used to retrieve the filtered records.

1. Catagory
2 Sub Catagory (if any)
3. Difficulty

I think I should add an index with the 3 fields above into MySQL

From the results set I want to randomly choose x amount of ID's where x is a number of questions

Thank you in advance

Peter
 

KMatle

Expert
Licensed User
Longtime User
Another one: Usually you add an unique ID (autoincrement). So each entry in a table is addressable exactly. Example: A customer ID. So if you have 1500 questions and the ID is an integer just generate e.g. 10 integer values between 1 and 1500 and do a select with it.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Another one: Usually you add an unique ID (autoincrement). So each entry in a table is addressable exactly. Example: A customer ID. So if you have 1500 questions and the ID is an integer just generate e.g. 10 integer values between 1 and 1500 and do a select with it.
That will not work as if there are 1500 questions in the database , only 300 will match the search criteria so the random must be in the result set of 300 and not in the total records
 
Upvote 0
Top