A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: MySQL Sorting

  1. #1

    MySQL Sorting

    I have a MySQL table with a varchar column that represents sections in a catalog. THe entries look like the following

    1.1
    1.2
    2.1
    2.7
    3.1
    3 - 4.4
    3 - 4.4
    4.1
    9.8, 9.9
    10.1
    12.7

    And so on. I want to be able to sort the rows based on this column in some sensical way (Section then subsection), but the entries 3-4.4 and 9.8,9.9 are throwing me off. Any ideas on how I can organize this to b sortable and updatable?

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Location
    Sydney, Australia
    Posts
    486
    First idea is to split this column in two and have start section and end section. This way all entries are in a standard format. When you retrieve the records you can just do a check and if start and end section are the same then just display one otherwise display "start" - "end"

    Let me know if I haven't provided enough / well explained detail; I'm in a bit of a rush.

    Design & Photography

  3. #3
    Thanks for responding

    Your idea makes sense, but the problem is that there is a possibility of a start and end sections or just multiple sections. Like

    9.7, 9.9, 10.2

    Even if it were just start and end. How would I store the sections in order to sort them? Split it into 4 columns, start_section, start_subsection, end_section, end_subsection and store as INTs?

  4. #4
    Network Guy
    Join Date
    Nov 2004
    Posts
    36
    If it were me (and depending on the size of the data), I'd probably add an additional column that was "order_by", and create an admin tool to manually sort the entries from 1 to 'n' ('move up', 'move down', etc) - then, you sort based on that known integer column rather than some variable string that you don't seem to have much control over.

  5. #5
    Gotcha, thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center