| От | Josh Berkus |
|---|---|
| Тема | Re: Random tuple? |
| Дата | |
| Msg-id | 200210171613.42600.josh@agliodbs.com обсуждение |
| Ответ на | Random tuple? ("Brendan LeFebvre" <brendanl@iname.com>) |
| Ответы |
Re: Random tuple?
|
| Список | pgsql-novice |
Brendan, > Is there available a routine, intrinsic or otherwise, that allows for simple > extraction of one(1) random tuple from a given table or query-result? > > (The specific application I had in mind was drawing a random product from a > webstore's inventory to feature on a front or section web page). SELECT tablea.*, random() as random_key FROM tablea ORDER BY random_key LIMIT 1; And you can modify the limit to select as many random rows as you want. -- -Josh Berkus Aglio Database Solutions San Francisco
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера