title: How to reset/clear order-by between two consecutive queries in CodeIgniter?
body: <p>I am trying to call 2 consecutive queries in CodeIgniter, the first of which has an order-by clause. The trouble is, CodeIgniter is trying to use the order-by clause for the second query as well and throwing an error. </p>
  
  <p>The code looks something like this:</p>
  
  <pre><code> ...
   $sql = $this-&gt;db-&gt;get_where('expenses',array('category_id' =&gt; $category_id));
   $this-&gt;db-&gt;order_by("date", "asc");
   $data = $sql-&gt;result_array();
  
   foreach($data as $expense_rec)
   {
       $expense_id = $data['expense_id'];
       $sql2 = $this-&gt;db-&gt;get_where('expense_details',array('expense_id' =&gt; $expense_id));
       $detail_rec = $sql2-&gt;result_array();
   }
   ...
  </code></pre>
  
  <p>For the second query, the script throws the following error: </p>
  
  <pre><code>Unknown column 'date' in 'order clause'
  
  SELECT * FROM (`expense_details`) WHERE `expense_id` = '4' ORDER BY `date` asc
  </code></pre>
  
  <p>Is there a way I can reset the order-by before calling the second query?</p>
  
  <p>I am using CodeIgniter 1.7</p>
  
  <p>P.S. I know that I can join the two queries into one but I am curious to know if there is a way for the above code to work in CodeIgniter.</p>