Sort by 2 fields

4 posts by 3 authors in: Forums > CMS Builder
Last Post: July 11, 2012   (RSS)

Re: [degreesnorth] Sort by 2 fields

By gkornbluth - July 10, 2012

Not sure, but have you tried 'unit_no DESC' ?

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Sort by 2 fields

By degreesnorth - July 10, 2012

Thanks, tried that, but it still doesn't work?

Re: [degreesnorth] Sort by 2 fields

By Jason - July 11, 2012

Hi,

The problem here is that your unit numbers (ie F14, F8, etc) are strings and are being sorted alphabetically. MySQL cannot tell that this is a letter followed by a number. The easiest solution here, would be to store your unit numbers as actual numbers (ie, 14, 8, etc) and then sort. If you need the "F", you could have a field for unit_number_prefix and you can output in front of the number for display.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/