priti narang
priti narang

Reputation: 236

MySql Full Index search not working

I set the example code here

http://sqlfiddle.com/#!2/6aa9ec/1

Below mentioned DB query used for searching the word Samsung but its not working

SELECT `idREQUEST`, `USER_NAME`, `idCATEGORY`, `TITLE`, `DESCRIPTION`, `IMAGE_URL1`, `IMAGE_URL2`, `IMAGE_URL3`, `POST_DATE`
    FROM `requests`
    WHERE MATCH (`TITLE`,`DESCRIPTION`) AGAINST('Samsung')

Upvotes: 0

Views: 58

Answers (2)

M Khalid Junaid
M Khalid Junaid

Reputation: 64476

You can use Boolean Full-Text Searches

SELECT `idREQUEST`,
`USER_NAME`, 
`idCATEGORY`, 
`TITLE`,
`DESCRIPTION`, 
`IMAGE_URL1`, 
`IMAGE_URL2`,
`IMAGE_URL3`, 
`POST_DATE`
FROM `requests`
WHERE MATCH (`TITLE`,`DESCRIPTION`) AGAINST('+Samsung' IN BOOLEAN MODE)

According to docs

MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier. With this modifier, certain characters have special meaning at the beginning or end of words in the search string. In the following query, the + operator indicate that a word is required to be present, respectively, for a match to occur.

DEMO

Upvotes: 2

Payam
Payam

Reputation: 487

This query looks for tiles and descriptions which the value is merely 'Samsung' But there are no entries in your table which are only 'Samsung'. Hence I'd suggest you to use %

SELECT `idREQUEST`, `USER_NAME`, `idCATEGORY`, `TITLE`, `DESCRIPTION`,
`IMAGE_URL1`, `IMAGE_URL2`, `IMAGE_URL3`, `POST_DATE`
 FROM `requests`
  where  `TITLE` like '%Samsung%' or `DESCRIPTION` like '%Samsung%'

This is the link

Upvotes: 0

Related Questions