Solved

MySQL Fulltext Search with Multiple Tables

Posted on 2010-11-21
1
480 Views
Last Modified: 2012-05-10
Hi, I'm trying to write a search query. I'm trying to take advantage of the "Natural Language" search capability.

Here is my query:

SELECT person.personid, person.firstname, person.lastname, facility.name, state.stateLongName, detail.description
FROM person
LEFT JOIN facility ON person.facility = facility.facilityid
LEFT JOIN detail ON person.personid = detail.personid
LEFT JOIN state ON facility.state = state.stateID
WHERE
MATCH (person.firstname, person.lastname, facility.name, state.stateLongName, detail.description)
AGAINST ('Texas')


I have FULLTEXT indexes set up on each of the columns in the MATCH part of the query.

I get the following error:
#1210 - Incorrect arguments to MATCH

Any thoughts on what I'm doing wrong?  I'm using MySQL 5.0.

0
Comment
Question by:ipeng
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 34183983
you will need to do like this, using either AND or OR, depends on what exactly you need to be the results.
I post with OR, you can change as needed:
SELECT person.personid, person.firstname, person.lastname, facility.name, state.stateLongName, detail.description
FROM person
LEFT JOIN facility ON person.facility = facility.facilityid
LEFT JOIN detail ON person.personid = detail.personid
LEFT JOIN state ON facility.state = state.stateID
WHERE MATCH (person.firstname, person.lastname) AGAINST ('Texas')
   OR MATCH (facility.name) AGAINST ('Texas')
   OR MATCH (state.stateLongName) AGAINST ('Texas')
   OR MATCH (detail.description) AGAINST ('Texas')

Open in new window

0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question