M
M
Mouvdy2021-08-01 17:57:56
MySQL
Mouvdy, 2021-08-01 17:57:56

How to correctly make Mysql "exact" like query?

There is a table with articles,

In it I need to find all the records where the word " trọn " occurs in the article

SELECT * FROM `url_content` WHERE `content` LIKE '% trọn %' limit 2


How to make a request correctly so that there are NOT similar words, for example: "tron", trơn" and so on?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mouvdy, 2021-08-02
@Mouvdy

My solution was the following:
It was possible to LIKE, but I went by MATCH AGAINTS since all articles weigh about 70 GB.
And then in PHP - strpos(); to find a specific key.
That turned out to be the fastest.

A
Akina, 2021-08-01
@Akina

  1. Use not LIKE, but substring search functions (INSTR or LOCATE)
  2. Set required collation (up to BINARY)

B
BasiC2k, 2021-08-01
@BasiC2k

Learn regular expressions. Then you will be able to build the query very precisely.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question