数据库—MySQL中contains怎么用?

contains经常会用在where子句中,方法为:SELECT * FROM table_name WHERE CONTAINS(fullText_column,'search contents')。

举例子,假设有个学生表,其中包含学号(num)、姓名(name)、性别(sex)、家庭所在城市(city)。

例一 查询家在上海的学生学号、姓名。

方式一

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

方式二

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

例二 查询性别为女生的学生信息。

方式一

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

方式二

select *
from student
where sex=“女”

通过这个例子,可以看出,contains的用法就是用来查询其所包含的参数。

猜你喜欢

转载自blog.csdn.net/weixin_43271894/article/details/108767231