Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8350555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:21:09+00:00 2026-06-09T08:21:09+00:00

My problem is that the website I’m currently working on has two tables for

  • 0

My problem is that the website I’m currently working on has two tables for products and there’s a search function that only searches one of the tables. I’d like to extend the search page of the website to cover both tables.

Effectively, I need two queries, which join their result set so I can use PHP to calculate relevancy to the user’s search query.

mysql_query("SELECT * FROM product WHERE title LIKE '%$keyword%' OR content LIKE '%$keyword%'")

title is a field that is on the product_spray table as well, as is content. How can I modify the above query to include results from the product table and the product_spray table?

I’m not sure it’s a JOIN that I need, because there’s no link between the two tables, they’re exclusive to each other. Though, I’m not very experienced with MySQL, so if there’s something I’m missing, let me know.

I’ve tried this:

mysql_query("SELECT * FROM product, product_spray WHERE product.title LIKE '%$keyword%' OR product.content LIKE '%$keyword%' OR product_spray.title LIKE '%$keyword%' OR product_spray.content LIKE '%$keyword%'")

The result set doesn’t come out correctly, it seems to combine the results.

Essentially, what I need is to have a single query, but using two exclusive SELECT statements. Can this be done?

I’d even be open to doing something in PHP that will allow combining the result set of two queries.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:21:10+00:00Added an answer on June 9, 2026 at 8:21 am

    I guess you want to join the rows (not the columns right?). And to solve your problem, you will use UNION for this

    SELECT  columnA
    FROM    product
    WHERE   title LIKE '%$keyword%' OR 
            content LIKE '%$keyword%'
    UNION
    SELECT  columnA
    FROM    product_spray
    WHERE   title LIKE '%$keyword%' OR 
            content LIKE '%$keyword%'
    

    just make sure that both queries have the same column in the result set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a website, whose URL is http://lathamcity.com/ The problem that
I'm currently designing this website http://avs.mybigcommerce.com . The problem is that my styles.css isn't
I'm working on a website that has a forum area, I will probably use
I'm currently working on a website that dynamically builds a city made of little
Currently I am working on an existing website that was initially created using SMF
My problem is that the website I built with django has 100s of links
the problem is that my website consists of only one page which contain a
So there is this website that has a login form. I want to log
I am working on a website that currently uses the old style frames. I
I have been optimizing my website but the one problem that stands in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.