Title: Help with constructing custom select query for posts
Last modified: August 20, 2016

---

# Help with constructing custom select query for posts

 *  [zenwebb](https://wordpress.org/support/users/zenwebb/)
 * (@zenwebb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/help-with-constructing-custom-select-query-for-posts/)
 * I’m trying to put together a portfolio on my site that groups posts based on 
   categories, and I need some help with the custom SELECT query to make it happen.
 * Every post I want to show up in my portfolio page is put into a category called“
   Portfolio”, as well as several specific categories. Therefore, I am needing to
   come up with a SELECT query that has the following form:
 * (pseudo-SQL)
    “SELECT * FROM posts WHERE category = ‘(Category1 || Category2 
   || Category3) && Portfolio'”
 * But my SQL is a little rusty. Can I get some help? 🙂

Viewing 1 replies (of 1 total)

 *  Thread Starter [zenwebb](https://wordpress.org/support/users/zenwebb/)
 * (@zenwebb)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/help-with-constructing-custom-select-query-for-posts/#post-3259434)
 * *bump*. Still having issues with this.
 * I’ve come across the WP_Query documentation and found the “cateogory__and” and“
   category__in” operators, but no mention of constructing complex queries using
   both. I almost need something that is nested, such as “category__and( category__in(
   1,2,3), 4)”. Any ideas?

Viewing 1 replies (of 1 total)

The topic ‘Help with constructing custom select query for posts’ is closed to new
replies.

 * 1 reply
 * 1 participant
 * Last reply from: [zenwebb](https://wordpress.org/support/users/zenwebb/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/help-with-constructing-custom-select-query-for-posts/#post-3259434)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
