14
I have a classified system where I do a search with PHP and Mysql using LIKE
in two camps:
campo1 like '' or campo2 like ''
The problem is when I’m looking for something like, "Green car" it doesn’t display anything because "car" is contained in field 1 and "green" in field 2, or even car comes with a word in the middle before "Green".
Could someone give me a tip on how to improve this search?
I tried to use:
SELECT description, title , MATCH ( title, description ) AGAINST ( '$busca' ) AS Score
FROM qtc_ads WHERE MATCH ( title, description ) AGAINST ( '$busca' )
ORDER BY Score DESC LIMIT 50
However Mysql informs me that the fields do not support this type of search and I do not know if this is the best way.
SQL that I currently use to search on my system:
SELECT * FROM `qtc_ads` AS `qtc_ad` WHERE `status` = 1 AND `title` LIKE '%l200%' (1)
Put the SQL you are using.
– Lucas Henrique
You are trying to use FULLTEXT search, which seems to be a good way. But for this to work, the columns in question need to have FULLTEXT indexes. Was this the error you mentioned? It would be nice to post the exact message.
– bfavaretto
SELECT * FROM
qtc_ads
ASqtc_ad
WHEREstatus
= 1 ANDtitle
LIKE '%car%'– joao_coelho
You want to search for "car" in the campo1 and campo2 and "green" in the campo1 and campo2?
– Lucas Henrique