Most efficient way to select a random table row where column is true?

goonergooner Lancaster, PAMember Posts: 135
edited September 2015 in Working with GS (Mac)

I would like to select a random row where the column "isActive" has a value of true. I currently have about 10 rows with 3 of them having "isActive" set to true. The further along in the game you get, more of the rows will be set to true, making more of them available to be selected.

I am currently attempting this by having a duplicate table that gets populated by checking each row in the master table. If "isActive" is set to true in the master table then I want to insert this row into the duplicate table. When all rows have been inserted into the duplicate table, I can select a random row with something like random(1, tablerowcount(tableDuplicate)).

Is this too convoluted and is there a simpler way? Use attributes instead of table? Any advice is well appreciated.

Comments

Sign In or Register to comment.