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
- Can I force WP_Query to return no results?
- Post_count only shows the number of results per page
- Pagination with custom SQL query
- Return only Count from a wp_query request?
- WP Query where title begins with a specific letter
- Search custom taxonomy term by name
- how does $wpdb differ to WP_Query?
- 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
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Want to redirect if search query match exact title of any post
- 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
- How to support multiple search terms query within one process?
- How can I connect to another WP database and use WP_Query?
- Pagination broken when merging search results with additional WP_Query
- Custom search form with empty parameters
- How to search by title or tags exclusively?
- WordPress search exact match
- Pagination wont work with search results template [duplicate]
- 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
- Get number of comments after modifying comment query
- How to change a custom query into a standard loop?
- WordPress custom search form with pre_get_posts not work
- Search – Ajax – Alter Query Parameters with Pagination
- How to count data records in wordpress which have same meta_value in wp_postmeta table?
- Add custom search results to main WP search [duplicate]
- Multiple search queries on one page
- Should close $wpdb via $wpdb->close()
- tax_query shows no results if nothing is selected
- Searching through different categories on different pages code is not working
- $wpdb->insert inserting two rows in database
- WP Query search for attachments and their exact title
- Get the Plugin Which Triggered a MySql Query in WordPress?
- WP_Query’s “request” SQL Query
- Including only current user’s posts in search
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Detect featured image among the attached images
- is_search was called incorrectly
- How would I format a query that depends on post parent taxonomy
- Mysql query LIKE not working
- How do I search inside specific taxonomies in WordPress
- Modifying the Search Results
- Custom category search box for WordPress
- Select from wp_post and multiple meta_value from wp_postmeta
- Refine search results using WP_Query
- How to find exact match for search term in WP_Query? What is the additional string added in LIKE query in WP_Query?
- Order by custom table and multiplication
- Search Posts with Custom Fields as query
- How to correctly pass values to wpdb->prepare()?
- Complex date range with WP_Query and BETWEEN
- Creating a custom search for a specific post type
- $wpdb select date range of posts
- What’s the purpose / logic of split_the_query in WP_Query->get_posts
- WPDB query – decrypting DB data
- Custom Search Result Page displaying only 1 result.
- How to loop for every result found in the_content() when using the search query?
- Assigning a meta_query value based on regexp to wp_query fails
- How to delete taxonomy term when a wordpress user is removed?
- showing all search result in one template
- 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?
- Order By table field comment_status in WordPress > 4.0
- 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
- Custom Query num_rows returns wrong amount
- wp_query ‘s’, search filter with pagination is not working
- 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)
- Multiple Search Terms WP_Query
- Filtering posts from different categories into different section by doing WP_Query only once
- Iterating through $wpdb query without using get_results for large query results
- Extend product search with meta in WooCommerce
- WP Query Args – Title or Taxonomy Value
- Display filtered results into custom page
- WordPress pagination not working on template search.php
- Cutom wp_query for geolocation search, pagination not working
- wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’
- Search Query for multiple categories using ‘OR’ but having certain categories be ‘AND’
- query_vars overriding WP_Query args
- how can I override The Events Calendar query modifications?
- 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
- Show all data in database table and make it into an interactive table
- How to make search for posts using get method?
- Categorising search results based on Custom Fields
- How to query custom post types with mixed AND & OR statements for custom fields