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

  • Home
  • SEARCH
  • 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 6609145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:41:05+00:00 2026-05-25T19:41:05+00:00

I have a multiple input search form, that has 2 text boxes. One text

  • 0

I have a multiple input search form, that has 2 text boxes. One text box for “searchWords” and the other for “specificPeople”.

In the first text box, you may have “Dorchester Hotel London”, and in the second, you may have “Brad Pitt/Angelina Jolie”. Using ASP, I convert the second text box value to a format that my IN clause will accept, such as this (‘Brad Pitt’,’Angelina Jolie’).

SELECT photoSearch.photoID, Left(photoSearch.caption,25), photoSearch.allPeople, photoSearch.allKeywords
FROM photoSearch
JOIN ( photoPeople INNER JOIN people ON photoPeople.peopleID = people.peopleID)
ON photoSearch.photoID = photoPeople.photoID AND people.people IN ('Brad Pitt','Angelina Jolie')
WHERE MATCH (caption, allPeople, allKeywords) AGAINST ('+dorchester +hotel' IN BOOLEAN MODE)
AND
photoSearch.dateCreated BETWEEN '2011-07-21' AND '2011-10-23'
ORDER BY photoSearch.dateCreated

This works without errors but it’s not producing records that have Brad and Angelina together. It shows records of Brad alone and records of Angelina alone. So this is where I first realised that an IN clause works like an OR.

How is it possible to amend this query, to return rows that have both of these specific names, rather than either of them?

My DB looks similar to this:

photoSearch
photoID     INT / AUTO / INDEX
caption     VARCHAR(2500) /  FULLTEXT
allPeople   VARCHAR(300) / FULLTEXT
allKeywords VARCHAR(300) / FULLTEXT
dateCreated DATETIME / INDEX

photoPeople
photoID     INT / INDEX
peopleID    INT / INDEX

people
peopleID    INT / INDEX
people      VARCHAR(100) / INDEX

Any help gratefully received… as always 🙂


An example of what is inside the tables:

photoSearch
photoID     |       caption         |           dateCreated
1900                Dorchester Hotel...         2011-10-03

'photoPeople'
[photoID]       |   [peopleID]
1900                147
1900                148

'people'
[peopleID]      |   [people]
147                 Brad Pitt
148                 Angelina Jolie
  • 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-05-25T19:41:05+00:00Added an answer on May 25, 2026 at 7:41 pm

    Join to the photoPeople and people tables n times, where n is the number of people you are searching for:

    SELECT photoSearch.photoID, Left(photoSearch.caption,25), photoSearch.allPeople, photoSearch.allKeywords 
    FROM photoSearch 
    JOIN ( photoPeople AS pp1 JOIN people AS p1 ON pp1.peopleID = p1.peopleID) 
    ON photoSearch.photoID = pp1.photoID AND p1.people = 'Brad Pitt'
    JOIN ( photoPeople AS pp2 JOIN people AS p2 ON pp2.peopleID = p2.peopleID) 
    ON photoSearch.photoID = pp2.photoID AND p2.people = 'Angelina Jolie'
    WHERE MATCH (caption, allPeople, allKeywords)
          AGAINST ('+dorchester +hotel' IN BOOLEAN MODE) 
    AND photoSearch.dateCreated BETWEEN '2011-07-21' AND '2011-10-23' 
    ORDER BY photoSearch.dateCreated 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a search program that has multiple input text boxes that correspond to
I have an application that has multiple states, with each state responding to input
I have multiple input textboxes in my page. I want to reset particular text
I have a form element that contains multiple lines of inputs. Think of each
I have a search page that is used in multiple places with multiple 'themes'
I have an input string containing multiple lines(demarcated by \n). I need to search
In a pretty typical scenario, I have a 'Search' text box on my web
On simple forms with one text box pressing enter submits the form (and this
I'm just an basic SQL user (mySQL+php now). I have search box with multiple
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select

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.