Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looking for suggestions on method to order records.

    I'm working on a Photo Gallery and currently working on a way order The photos. I've set up the following fields: Title, Description, photo_url, display_order. What I'm doing is using the display order to set the order the photos are displayed

    Now here's the problem I'm running into. I have a gallery that has a bunch of photos and I only care about setting the order on say 5 of the photos and don't care about the order of the rest so I enter 1-5 in display_order on those 5 records. When I issue the SQL search "order by display_order" all the records with null in the display_order are comming up first, rather then the 5 records with the 1-5 in display_order.

    Any suggestions on how to get those 5 records to display first and in order?
    Last edited by musher; 02-26-2007 at 10:30 PM.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    hmm...postgres sticks nulls at the end...

    you could try:
    order by (display_order IS NULL), display_order
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

  • #3
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks GJay,

    "order by (display_order IS NULL), display_order" did the trick, have never seen an order by done like that.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians


  •  

    Posting Permissions

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