On 11 Nov 2016, at 12:59pm, Niall O'Reilly <[email protected]> wrote:

>  IIUC, OP wishes to pick at random from the items which haven't yet been
>  used in the current cycle.

That's different.  To do that, you just need a flag 'seen' yes / no.

When you enter a new quote set seen to 'no'.

To search for a random quote:

    SELECT id,quotetext FROM quotes WHERE seen='no' ORDER BY RANDOM() LIMIT 1

If the SELECT returns zero rows then do

        UPDATE quotes SET seen='no'
        SELECT id,quotetext FROM quotes WHERE seen='no' ORDER BY RANDOM() LIMIT 
1

then do

    UPDATE quotes SET seen='yes' WHERE id= <id from last SELECT>

Worth noting that the above method, although it does what was asked, means that 
it is possible to see the same quote twice in a row.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to