0
Let’s say I have a table called carros
.
In this table I have some registered cars. Ex:
ID | Name
1 | Corsa Amarelo
2 | Camaro 2 Portas Amarelo
3 | Camaro V12 Amarelo
4 | Camaro Esportivo Amarelo
5 | Fusca Amarelo
6 | Camaro Amarelo
7 | Gol Amarelo
8 | Ferrai Vermelha
9 | Ferrari 490 cv vermelha
If I use the following query SELECT * FROM carros WHERE carros_name LIKE %camaro amarelo%
I will result in just the following line
6 | Camaro Amarelo
If I just split the search terms like this carros_name LIKE %camaro amarelo% OR carros_name LIKE %camaro% OR carros_name LIKE %amarelo%
the result comes all mixed.
But I would like to get as a result everything that has the words of the search term, organizing the results by the term more similar on. Something like:
ID | Name
1 | Camaro Amarelo
4 | Camaro V12 Amarelo
5 | Camaro Esportivo Amarelo
3 | Camaro 2 Portas Amarelo
2 | Corsa Amarelo
6 | Fusca Amarelo
7 | Gol Amarelo
As you can see in the result above, the result comes with a classification where the term searched appears first, results with all the words of the search in 2 seconds and finally any result that has any word of the term searched.
Note: 'ranking' does not exist, the right term is
classificar
orordenar
– Sveen
Use the
match ... against
(https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html) instead oflike
...– Inkeliz
@Inkeliz this solved! Thank you very much! If you formulate a reply I can vote as the best.
– ivan veloso