CodeIgniter Forums
SQL Query - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: SQL Query (/thread-22313.html)

SQL Query - El Forum - 09-04-2009


I have the following SQL query.

function get_panel()
        $this->db->select('Object_ID, Object_Desc');
        $this->db->order_by('Primary_ID', 'random');
        $query = $this->db->get('panelbase');
        return $query->result_array();


Please ignore, I have found a solution. Apologies for a pointless thread.

SQL Query - El Forum - 09-04-2009


I think I read once that random order by is expensive compared to calculating the max row number, then using a php random function to pick a row #, and doing a lookup of that row.

SQL Query - El Forum - 09-04-2009

Okay, well I will google up on it. Thank you very much for the advice.