Re: Rand() Emulation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Becoming Digital wrote:

Ultimately, my goal is to emulate mysql's ->
SELECT * FROM TABLE ORDER BY RAND() LIMIT (X)

for other databases that do not support RAND().



Which are those?


Currently mySQL, PostgreSQL, and MSSQL.




To me the idea above would work, but it hinges on if that rand column,
doesn't have gaps.



Use your table's primary key, assuming there is one. This saves creating what is otherwise unncessary data, but you'll still face "gaps" if records are deleted.

Unfortunately, my primary keys are not numerical, thus the creation of a column with numerical values.

Hopefully by next week, I should be ready to try out my psuedo code, and see how it plays out.
If it doesn't work out, I guess no random selection happening in my code :)


Thanks


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux