MySQL Natural Sort Order By on Non-Numeric Field Type

/ Published in: PHP
Save to your folder(s)

Copy this code and paste it in your HTML
  1. // CodeIgniter snippet
  2. //+0 is my sneaky way of tying to force numeric sorting on non-numeric fields
  3. $this->db->order_by('dateIssued DESC, invoice_number+0 DESC');
  5. // MySQL snippet
  6. // SELECT * FROM SampleData ORDER BY data_char+0;


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.