Re: Random query question

2011-05-20 Thread Sarpidon
Thank you guys. Going through your suggestions now. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send e

Re: Random query question

2011-05-19 Thread ShadowCross
If you are using MySQL as your database backend, read http://www.desilva.biz/mysql/random.html (found by Googling "mysql random row"). If you are not using MySQL, check if your database has a similar function. On May 19, 5:56 am, Sarpidon wrote: > Hi everybody. > > I have a companies table and

Re: Random query question

2011-05-19 Thread dreamingmind
one simple way would be to fetch all the records, then generate two non-equal random numbers in the range of found records, then pluck those two out of the result array. The returned records are numbered 0-10 in that array so it will be very simple to do! http://us.php.net/manual/en/function.rand.

Random query question

2011-05-19 Thread Sarpidon
Hi everybody. I have a companies table and those companies have promotions. Each company can have up to 10 promotions but only 2 can be displayed from each company at one time. I've been trying to figure out how to generate a single query that will select only 2 promotions randomly from each compa