I believe you’re looking for SQL UNION.
Related Posts:
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- How to correctly pass values to wpdb->prepare()?
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Pagination with custom SQL query
- Return only Count from a wp_query request?
- SQL query equivalent to WP User Query
- how to retrieve specific product attribute value in an sql query?
- Select from wp_post and multiple meta_value from wp_postmeta
- $wpdb select date range of posts
- List of the years with posts presented
- Optional Meta Query
- Custom Query num_rows returns wrong amount
- Editing the default wordpress search
- Iterating through $wpdb query without using get_results for large query results
- WP Query related posts by tags
- Order by summing multiple values
- Include data from custom table in WP_Query
- How to pass orderby params to $wpdb->prepare()?
- Is it possible to query from external database? [duplicate]
- Make a SQL query with wpdb in WordPress
- WordPress query posts with multiple post_meta data
- List of ways to access WordPress database?
- Query where ANDing slug values not working
- How to SQL query posts IDs by categories AND authors?
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- Passing a SQL query to the WP Query
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- Slow wp_posts and wp_postmeta query using Advance Custom Fields
- What argument does my function need to echo get_results() query results
- Include post_status check within $wpdb query
- wpdb get_results() returns only 2 rows
- wpdb LIKE request shows all database data
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- How to avoid filling up an array each time I run a WP_query?
- Randomly select one of last 3 posts
- Unable to paginate a custom page query
- Include one page/post into query which is already returning posts
- I am officially missing something about transient posts
- Insert images into wordpress post with a query
- Why doesn’t my WP Meta Query return any results?
- How do I query for posts by custom meta and those that have been stickied?
- WordPress SQL JOIN query
- WP_Query meta compare must include ALL array values
- Start Query from 2nd Post without offset
- get_var is neither a string, integer, or array …?
- Use have_posts() with array of post results retrieved by $wpdb->get_results
- how to translate countries output from wp database?
- What’s wrong with this wpdb query?
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- meta_query where the meta value is not the post title
- Post incorrectly excluded when using “category__in”?
- Query multiple post types, but different order for each
- Multi-layered WP_Query
- `offset` WP_Query argument dont work via `pre_get_posts`
- Filter products on category AND tag
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- SQL query injection with fifu image
- duplicated posts when using pagination
- Pagination of custom page with custom fields query
- Query pages created by deleted users
- WP_Query() not working as expected
- Save queried result into database
- Customising the default wordpress search functionality
- WP Query – grouping posts by same meta key, adding together values from another key
- setting offset to category number in archive page
- Woocommerce Get Orders By Meta Value
- pre_user_query vs pre_get_posts
- Exclude post from wp_query based on custom field boolean
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Delete oldest wordpress post (SQL query)
- Get posts that match defined arrays of tags
- What is the equivalent WP_Query of a SQL Query?
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- Adding nofollow to all the post links in get_posts with pre_get_posts or WP_Query
- Meta query orderby meta_value_num sorting by role first
- How to get meta key list efficiently?
- How to get user avatar via WPDB
- Order posts by tags count?
- Query against multiple locations within single custom post type post
- Why pagination is not working with tax_query param?
- Translating WP query into to SQL query
- Query Posts | Combining multiple form inputs into query arguments to generate one filter result
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- How to get_comments() ordered by date and parent?
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- How to query 5 users in random who have published more than 10 posts
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- Add to search posts query array with post IDS which will appear first
- Filtering posts for unique titles, only the most recent
- return child post if available otherwise parent post
- Search has query that will return no results
- Is my code correct?
- How to make a search query if not found in post table then search in postmeta table?
- How to search CPTs in draft using get_page_by_title()