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 6550173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:11:02+00:00 2026-05-25T12:11:02+00:00

Any full-text, MySQL experts out there? I wrote a question yesterday asking for any

  • 0

Any full-text, MySQL experts out there?

I wrote a question yesterday asking for any suggestions on how to use full-text search with a lot of joins, a bit lazily, I hadn’t actually made an attempt.

Since then, I’ve a had a good attempt at mastering it myself, building a few successful test queries, against my full-text fields. If I do NOT use any joins, and query each field individually, the full-text functions work perfectly and relevance/boolean works great with great performance too… but… as soon as I add my joins to run the full query, it runs forever and ever.

Can anybody spot anything in my query that might cause this to happen, because as an amateur, I really can’t see it!

SELECT

photos.photoID,
photos.headline,
photos.dateCreated,
MATCH (people.people) AGAINST ('+sarah +harding' IN BOOLEAN MODE) AS Rel1

FROM photos

LEFT JOIN ( photoPeople INNER JOIN people ON photoPeople.peopleID = people.PeopleID ) 
ON photos.photoID = photoPeople.photoID AND MATCH (people.people) AGAINST ('+sarah +harding' IN BOOLEAN MODE)

WHERE

photos.photoStatus = 'Live'

GROUP BY

photos.photoID

ORDER BY Rel1

This is one of my successful, individual, queries:

SELECT

photoID,
headline,
dateCreated,
MATCH (caption) AGAINST ('+sarah +harding' IN BOOLEAN MODE) AS Relevance

FROM photos

WHERE

photoStatus = 'Live'

AND

MATCH (caption) AGAINST ('+sarah +harding' IN BOOLEAN MODE)

ORDER BY Relevance

This is the DB schema:

photos (tbl)
photoID             INT(11)         Primary     Auto-Increment
headline            Long-Text
caption             Long-Text / FULLTEXT
dateCreated         DateTime

people (tbl)
peopleID            INT(11)         Primary     Auto-Increment
people              VarChar(255) / FULLTEXT

photoPeople (tbl)
photoID             INT(11)
peopleID            INT(11)

keywords (tbl)
keywordID           INT(11)         Primary     Auto-Increment
keyword             VarChar(255) / FULLTEXT

photoKeyword (tbl)
photoID             INT(11)
keywordID           INT(11)

photoContributor (tbl)
photoID             INT(11)
contributorRef      VarChar(100) / FULLTEXT

And this is my EXPLAIN print out:

id  select_type         table               type        possible_keys       key     key_len     ref     rows
1   SIMPLE              photos              ALL         NULL                NULL        NULL        NULL        89830
1   SIMPLE              photoContributor    ALL         NULL                NULL        NULL        NULL        149635  
1   SIMPLE              photoPeople         ALL         NULL                NULL        NULL        NULL        110606
1   SIMPLE              people              eq_ref      PRIMARY             PRIMARY     4       1   
1   SIMPLE              photoKeyword        ALL         NULL                NULL        NULL        NULL        699102  
1   SIMPLE              keywords            eq_ref      PRIMARY             PRIMARY     4       1

My website visitor should be able to search for:
“Brad Pitt Angelina Jolie Dorchester Hotel Sunglasses @MG” – This should find “Brad Pitt” and “Angelina Jolie” from the ‘people.people’ table and possibly the ‘photos.caption’ table too. It should also find “Dorchester Hotel” from the ‘photos.caption’ table, “Sunglasses” from the ‘keywords.keyword’ table and lastly, it should find “@MG” in ‘photoContributor.contributorRef’ table.

Any help on this would be gratefully received…

  • 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-25T12:11:03+00:00Added an answer on May 25, 2026 at 12:11 pm

    I suggest using separate smaller queries and using UNION to create a combined result set.

    Here is another question with a similar task.
    Mysql Full text search across more than one table

    Update

    SELECT "Photos" AS TableName, photoID AS ID, MATCH (caption) AGAINST ('+sarah +harding' IN BOOLEAN MODE) AS Relevance
    FROM photos
    UNION ALL
    SELECT "People" AS TableName, peopleID AS ID, MATCH (people) AGAINST ('+sarah +harding' IN BOOLEAN MODE)
    FROM people
    UNION ALL 
    SELECT "Keyword" AS TableName, keywordID AS ID, MATCH (keyword) AGAINST ('+sarah +harding' IN BOOLEAN MODE)
    FROM keyword
    

    I don’t really know what data you have but it would produce something like:

    Table Name | ID | Relevance

    Photos | 1 | 1

    Photos | 2 | 0

    People | 1 | 1

    Keyword | 10 | 1

    You can add additional where clauses to suit your needs but this is the basic idea.

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

Sidebar

Related Questions

I'm planning to use SOLR for full-text search. Question: when I update my MySQL-database,
After learning how to do MySQL Full-Text search, the recommended solution for multiple tables
I've read about full-text search functions in mysql. But in these methods you have
I am working with MySQL full text search but find it lacking in situations
I'd like to have the results of my full text search in MySQL sorted
I'm using this query to perform a full text search on a MySQL database:
I am trying to get a full text search on a mysql database. The
I'd like to implement fulltext search for a datatable ? are there any .net
Is there any difference(means full/limited access) in iphone SDK before and after enrolling in
Is there any CSS grid system that supports full viewport width? Most Grid System

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.