This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Is there an easy way to select a random entity from a collection with Lightspeed? Something like...
...would be ideal where 'n' is the number of random items required. :) (Although in my current scenario I only need one random item). I've seen a few posts about this but none of them are solved with what I'd call "an easy way". Maybe there's been an update to this since it was last asked. Thanks. |
|
|
Anyone....? |
|
|
Hi, There's nothing specific in LightSpeed that would help you do this. Off the top of my head, I'd probably send a query to the database manually and order the results in random order and then select the N first items in the result set. You can see an example of how to order randomly here: http://stackoverflow.com/questions/1117761/sql-query-to-return-rows-in-random-order Good luck! John-Daniel Trask |
|