I managed to solve this by taking s_ha_dum’s suggestion to use a UNION. It is as follows:
(SELECT ID, post_status, post_title, post_excerpt, post_content FROM wp_posts WHERE ((`post_title` LIKE '%diamond%') OR (`post_excerpt` LIKE '%diamond%') OR (`post_content` LIKE '%diamond%')) AND (`post_status` = 'publish' )) UNION (SELECT ref, StoreID, Article, subarticle, description FROM wp_hwproducts WHERE (`article` LIKE '%diamond%') OR (`subarticle` LIKE '%diamond%') OR (`description` LIKE '%diamond%')) ORDER BY `post_status` DESC;
Related Posts:
- Query with search and subscribers only output
- How to access custom WordPress database tables
- How to print the excuted sql right after its execution
- Post_count only shows the number of results per page
- Return only Count from a wp_query request?
- WP Query where title begins with a specific letter
- Search custom taxonomy term by name
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Is it true $wpdb->get_results is faster than WP_Query in most cases?
- Tracing the life of a query
- Use WP_Query with a custom SQL query
- How to make an activities stream mixing posts and comments?
- Pagination not working for Custom search form & custom result template
- Pagination broken when merging search results with additional WP_Query
- WordPress search exact match
- How do I search WordPress by different fields without a plugin?
- Multiple keyword search
- Looping through tabular data
- Using next/previous_posts_link with customised search
- WordPress custom search form with pre_get_posts not work
- WP Query search for attachments and their exact title
- How would I format a query that depends on post parent taxonomy
- Mysql query LIKE not working
- Modifying the Search Results
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Creating a custom search for a specific post type
- Custom Search Result Page displaying only 1 result.
- Querying on multiple taxonomies pulled from $_GET checkbox array not working?
- Is there any advantage of using default WordPress Search instead of creating a custom one?
- WP_Query Not Recognizing Taxonomy Parameter in Custom Search
- Search pages that are a child of the current page
- Include tags in WP_Query
- Search for multiple tags?
- Custom Search Not Consistent with Results
- Getting post revision and printing them on the post content site
- Editing the default wordpress search
- How to use wp_query to post count by search term > group post count by date > convert to json. (ex. result 12-21-2020 – 343)
- Iterating through $wpdb query without using get_results for large query results
- Extend product search with meta in WooCommerce
- Search by post id in a specific page then auto-redirect to searched post
- wp_Qwery works to slow
- Search for “2nd” also returns “22nd” in wp_query
- How to query custom post types with mixed AND & OR statements for custom fields
- Query most popular terms by taxonomy over 2 week period
- Which is faster wpdb & get_row or wp_query & ge_post_meta?
- Modify Search Query if original Query gave no results
- Is it safe to access the underlying mysqli object from \wpdb for custom queries?
- Why Query is returning empty array?
- Include post content of linked posts in search
- Make a SQL query with wpdb in WordPress
- How do I amend wp_query before it is run/executed?
- wp_query search not taking keywords with together for multiple words
- List of ways to access WordPress database?
- Multiple Rows in a using wp_query
- Specify strict ‘order by’ in WordPress query
- Search Page Returns Nothing
- Does WordPress have something like Drupal’s DB API?
- How to properly use AND / OR in custom search
- How to avoid bypass of search bar rules?
- Hide products in uncategorized category from search results
- How do you determine if a result in a search query is a post or a page?
- wp_query show all values
- change posts_orderby of the callback wp_query?
- How to restrict search on a certain page to only return results against custom taxonomies?
- Ignore image urls in wp_query search
- get_var is neither a string, integer, or array …?
- What’s wrong with this wpdb query?
- WordPress search WP_Query to cover multiple post types and their custom fields?
- My combination of ‘post_type’ and ‘tax_query’ not working?
- How to prevent WP_Query from filtering on ‘s’ but keep ‘s’ for other purposes?
- Add dynamic search to paginated WP_Query
- Save queried result into database
- Multiple WP_Query args combinations according to post type
- Display the search results like the original pages
- How to use jQuery validation to set the search bar to accept only a specific input?
- WordPress search page pagination displaying but not functional
- Search has query that will return no results
- WP Query – Search in title or author_name
- Limit default Search query to post_title
- Order & Orderby clause not working with custom query
- How can I modify standard search query to include also ACF custom fields values?
- What argument does my function need to echo get_results() query results
- Select Unique Posts for a List of Tags
- How To Use WP_Query To Get The Custom Post type Posts With Keywords
- How to make the default WordPress search return borader results
- WordPress WP_Query offset parameter not working with search parameter
- Add pagination to table generated by wp_query
- Fire query on ajax post url page
- Need help setting up a search form for wordpress [duplicate]
- Custom search: Search posts but display parent page in results
- Query posts by custom fields
- Different sql queries count indicator on the main page [closed]
- Searching in specific custom post type
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- Search (Custom Form, Custom Search Result)
- Help with showing text when something is entered in my search bar
- Filtering product search results using tags
- WordPress WP_Query Search (‘s’) With Multiple Search Terms
- Search results stuck on page 1
- Custom Taxonomy in custom REST API search