Title: matthewfdeville's Replies | WordPress.org

---

# matthewfdeville

  [  ](https://wordpress.org/support/users/matthewfdeville/)

 *   [Profile](https://wordpress.org/support/users/matthewfdeville/)
 *   [Topics Started](https://wordpress.org/support/users/matthewfdeville/topics/)
 *   [Replies Created](https://wordpress.org/support/users/matthewfdeville/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/matthewfdeville/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/matthewfdeville/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/matthewfdeville/engagements/)
 *   [Favorites](https://wordpress.org/support/users/matthewfdeville/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [SQL Query for Custom Posts with Ranking By Scores Submitted](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/)
 *  Thread Starter [matthewfdeville](https://wordpress.org/support/users/matthewfdeville/)
 * (@matthewfdeville)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/#post-2456303)
 * and the scores need to be added up across challenges. that’s where I’m getting
   stuck…
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [SQL Query for Custom Posts with Ranking By Scores Submitted](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/)
 *  Thread Starter [matthewfdeville](https://wordpress.org/support/users/matthewfdeville/)
 * (@matthewfdeville)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/#post-2456302)
 * this seems to be getting close:
 *     ```
       SELECT p . * , s . *
       FROM wp_posts p
       JOIN wp_postmeta s ON s.meta_key = 'score_value'
       WHERE p.id = s.post_id
       AND 1 = 1
       AND p.post_type =  'challenge_one'
       OR p.post_type =  'challenge_two'
       OR p.post_type =  'challenge_three'
       AND (
       p.post_status =  'publish'
       )
       ORDER BY s.meta_key ASC;
       ```
   
 * but the ordering doesn’t seem to be right.
 * anyone have any ideas?
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [SQL Query for Custom Posts with Ranking By Scores Submitted](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/)
 *  Thread Starter [matthewfdeville](https://wordpress.org/support/users/matthewfdeville/)
 * (@matthewfdeville)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/sql-query-for-custom-posts-with-ranking-by-scores-submitted/#post-2456300)
 * messing around, I’ve got this far:
 *     ```
       SELECT p . * , s . *
       FROM wp_posts p
       JOIN wp_postmeta s ON p.id = s.post_id
       WHERE 1 =1
       AND p.post_type =  'challenge_one'
       OR p.post_type =  'challenge_two'
       OR p.post_type =  'challenge_three'
       AND (
       p.post_status =  'publish'
       )
       ORDER BY p.post_date DESC
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)