[wp-trac] [WordPress Trac] #17065: Independent ASC/DESC in multiple ORDER BY statement.

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 8 00:44:45 UTC 2011


#17065: Independent ASC/DESC in multiple ORDER BY statement.
-------------------------------------+------------------------------
 Reporter:  ericmann                 |       Owner:  ericmann
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Query                    |     Version:  3.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |
-------------------------------------+------------------------------

Comment (by lukecarbis):

 My first trac comment - inspired by WordCamp GC. :)

 Possible stupid question - why do we require the orderby meta_key to be
 part of the meta_query?

 What about the usage case where I want to return results including but not
 limited to items that include the meta_key, and order by that meta_key.
 For example, I want to order posts by custom_meta_item, but I want to
 include posts that don't have any custom_meta_item.

 This could be achieved by adding a second postmeta INNER JOIN to
 $pieces['join'], and using CASE to order in $pieces['order'].

 We could use the same syntax, but avoid ignoring orderby[0]['meta_key'] if
 it's not included in the meta_query.

 Thoughts?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17065#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list