• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQL Query

#1
[eluser]georgerobbo[/eluser]
Hello,

I have the following SQL query.

Code:
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.

#2
[eluser]jedd[/eluser]
$this->db->limit(1);

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.

#3
[eluser]georgerobbo[/eluser]
Okay, well I will google up on it. Thank you very much for the advice.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.