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');
  4.  
  5. // MySQL snippet
  6. // SELECT * FROM SampleData ORDER BY data_char+0;

URL: http://derekallard.com/blog/post/mysql-natural-sort-order-by-on-non-numeric-field-type/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.