0

I have a db with a table called sections. In that is a field called head that has a full text index with 3 entries each a string. 2 entries have the word motorcycle and one has motorcycles. I can't seem to find a way to return all 3 if the term "motorcycles" is search.

I have tried

SELECT * FROM sections
     WHERE MATCH (head) AGAINST ('Motorcycles')

but it only returns the plural entry. I have also tried.

SELECT * FROM sections
   WHERE head like '%motorcycles%'

but that also only returns the plural entry. Is there a way to return all three rows based on "motorcycles"?

4

3 回答 3

1

Have you tried boolean mode?

where match (head) against ('+ Motorcycle*' in Boolean mode)

More information is here.

Your where clause has an extra "s":

 SELECT * FROM sections WHERE head like '%motorcycle%'
于 2013-03-30T18:07:33.670 回答
0

Assuming your question is more general than the specific motorcylce example you've given...I'm not aware of a way that you can relax the contraints directly in the SQL (without a stored proc to pre process the input). I'd suggest pre processing your input with a regex to remove/replace the chars that make the word plural. Then use like in the way that you have shown on the singular version of the word.

于 2013-03-30T18:09:53.047 回答
0

If i have got your Questions correctly I think you want something like this:

if (SELECT count(1) FROM sections WHERE head like '%motorcycles%')>1
begin
    select * FROM selections
     WHERE head like '%motorcycle%'
end
于 2013-03-30T18:12:41.680 回答