• Resolved fgshepard

    (@fgshepard)


    I have a custom query that works but I want to reverse the order. For some reason, changing ASC to DESC doesn’t seem to make a difference. Here is the SQL:

    SELECT wposts.*
    FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
    WHERE wposts.ID = wpostmeta.post_id
    AND wpostmeta.meta_key = 'Date'
    AND wposts.post_status = 'publish'
    AND wposts.post_type = 'post'
    AND wposts.post_date < NOW()
    ORDER BY MID(wpostmeta.meta_value,7,10), MID(wpostmeta.meta_value,1,2), MID(wpostmeta.meta_value,4,5) DESC

    The custom field contains date in mm/dd/yyyy format, and I’m sorting the results initially by using the MID function on the value (so it sorts by year, then month, then day). The results come out in order from oldest to newest. Swapping ASC and DESC doesn’t change the order. Any/All help much appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘ASC and DESC in SQL query not producing different results’ is closed to new replies.