Postgresql Random Rec Set - no Duplicates with Livecode
Pierre Sahores
psahores at free.fr
Thu Feb 3 02:17:22 EST 2011
'Morning Rick,
To avoid possible border effects, did you try how it goes in adding the distinct clause alike this :
SELECT DISTINCT *
FROM table
WHERE condition = true
ORDER BY hashfloat8(random())
LIMIT 10;
Best,
Pierre
Le 3 févr. 2011 à 04:06, Rick Harrison a écrit :
> Hi yet again Pierre,
>
> Ok, I did a test where I used the limit of 48 out of 49 records.
> It didn't pick even one duplicate. Hurray!!! The code must
> advance the record counter randomly so no duplicates
> occur. Nice, but unexpected.
>
> Ok, all is well now.
>
> Thanks again,
>
> Rick
>
> On Feb 2, 2011, at 9:41 PM, Rick Harrison wrote:
>
>> Hi again Pierre,
>>
>> How do I avoid picking duplicates though?
>>
>> Rick
>>
>> On Feb 2, 2011, at 6:09 PM, Pierre Sahores wrote:
>>
>>> Hi Rick,
>>>
>>> SELECT *
>>> FROM table
>>> WHERE condition = true
>>> ORDER BY hashfloat8(random())
>>> LIMIT 10;
>>>
>>> Are you sure that the order by + limit clauses used together can't suit exactly your needs ?
>>>
>>> Best,
>>>
>>> Pierre
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
--
Pierre Sahores
mobile : (33) 6 03 95 77 70
www.woooooooords.com
www.sahores-conseil.com
More information about the use-livecode
mailing list