ORDER BY random() with seed in SQLITE

前端 未结 4 804
别跟我提以往
别跟我提以往 2020-12-11 00:19

I would like to implement paging for a random set

Select * from Animals ORDER BY random(SEED) LIMIT 100 OFFSET 50  

I tried to set int to

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-11 01:19

    I use this for random from seed in my javascript game i am sure you can quite easily convert it to sql

    seed: function(max) {
        if(typeof this._random === 'undefined') this._random = max; // init on first run
        this._random = (this._random * 9301 + 49297) % 233280;
        return Math.floor(this._random / (233280.0) * max);
    }
    

提交回复
热议问题