Welcome Guest, Not a member yet? Register   Sign In
Pick random result from query.
#1

[eluser]Fantass[/eluser]
Hello, heres my query

Code:
$this->db->having('active', 1);
        $this->db->having('widerange', 2);
        $this->db->having('counter < assigned');
        $query = $this->db->get('anuncios');
Wich return me various results according to the search but i want to pick up a random one
I've tried with Mysql this query

Code:
SELECT * FROM `anuncios`  HAVING `active` = 1 AND `counter` < `assigned` AND `widerange` = 2 ORDER BY RAND() limit 1
What return me exactly what i want.

then i've try adding the line
Code:
$this->db->order_by("id", "RAND");
but nothing Sad...

Someone could help me?
THANKS.


Messages In This Thread
Pick random result from query. - by El Forum - 02-24-2012, 01:45 PM
Pick random result from query. - by El Forum - 02-24-2012, 02:54 PM
Pick random result from query. - by El Forum - 02-24-2012, 04:03 PM
Pick random result from query. - by El Forum - 02-24-2012, 04:36 PM
Pick random result from query. - by El Forum - 02-24-2012, 04:40 PM
Pick random result from query. - by El Forum - 02-24-2012, 09:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB