[wp-hackers] SQL: pulling WP data by multiple meta_key/value pairs
Simon Dunton - WP Sites
simon at wpsites.co.uk
Wed Jan 16 16:46:13 UTC 2013
That's pretty much what I'd do.
Build the query in WordPress using WP_query() and some meta_query parameters and then just print_r() or var_dump() what you get back from WP_query() which will contain the full SQL query amongst a load of other query bumf.
Simon
On 16 Jan 2013, at 16:33, Simon Blackbourn wrote:
> You can certainly query based on multiple key/values using the meta_query
> parameter. [1] & [2]
>
> You may then be able to sort on a third one by passing that in as the
> meta_key parameter and setting the orderby parameter to 'meta_value' [3],
> although i'm not 100% sure that will work in combination with the
> meta_query parameter.
>
> Then you can use the debug bar plugin [4] or any other method of logging
> the queries to grab the SQL.
>
> Simon
>
> [1]
> http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
> [2] http://scribu.net/wordpress/advanced-metadata-queries.html
> [3]
> http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
> [4] http://wordpress.org/extend/plugins/debug-bar/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list