Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql search for string and number using MATCH() AGAINST()

I have a problem with the MATCH AGAINST function.

The following query give me the same result:

SELECT * FROM models MATCH(name) AGAINST('Fiat 500')
SELECT * FROM models MATCH(name) AGAINST('Fiat')

How can I search for both strings and numbers in a column of a FULL TEXT table?

Thanks

like image 201
Gambric Avatar asked Jan 28 '13 22:01

Gambric


People also ask

What is match against in MySQL?

The search string is given as the argument to AGAINST(). For each row in the table, MATCH() returns a relevance value; that is, a similarity measure between the search string and the text in that row in the columns named in the MATCH() list. So, you need to sort them or remove the limit on your results.

How do I check if a string is a number in MySQL?

Learn MySQL from scratch for Data Science and Analytics To check if the given value is a string or not ,we use the cast() function. If the value is not numeric then it returns 0, otherwise it will return the numeric value. In this way, we can check whether the value is an integer or not.

How do I match a string in MySQL?

STRCMP() function in MySQL is used to compare two strings. If both of the strings are same then it returns 0, if the first argument is smaller than the second according to the defined order it returns -1 and it returns 1 when the second one is smaller the first one.

How do I match data in MySQL?

MySQL Compare Two tables to Find Matched RecordsFirst we do a UNION ALL of two tables to retain duplicate rows. Next, we do a GROUP BY to count records by id, order_date and amount columns to find records with count>1, that is records that occur more than once. We use the above query as subquery.


1 Answers

Just in case it helps others, if you're using InnoDB you need to use a different set of mysql.cnf properties

eg

show variables like 'innodb_ft%';

and in my.cnf set the following value instead of ft_min_word_len

innodb_ft_min_token_size=1
like image 200
ashario Avatar answered Oct 14 '22 15:10

ashario