Database-how to use contains in MySQL?

contains is often used in the where clause, the method is:SELECT * FROM table_name WHERE CONTAINS(fullText_column,'search contents')。

For example, suppose there is a student table, which contains student ID (num), name (name), gender (sex), and home city (city).

Example 1 Query the student ID and name of the student whose home is in Shanghai.

method one

select num,name
from student
where contains(city,“上海”)

Way two

select num,name
from student
where city=“上海”

Example 2 Query information about students whose gender is female.

method one

select *
from student
where contains(sex,“女”)

Way two

select *
from student
where sex=“女”

Through this example, you can see that the usage of contains is to query the parameters it contains.

Guess you like

Origin blog.csdn.net/weixin_43271894/article/details/108767231