mysql查找字符串函数

本文介绍了MySQL中用于查找字符串的函数,包括find_in_set、field、locate、position和instr等,详细阐述了它们的用法和区别。同时,还讲解了根据位置找字符串的elt和make_set函数,提供在数据库操作中查找和定位字符串的实用技巧。
摘要由CSDN通过智能技术生成

一、根据字符串找位置

find_in_set

第二个参数是以逗号隔开的,从第二个参数集合中查找第一个参数的位置

mysql> select find_in_set('mysql','oracle,sql server,mysql,db2');
+----------------------------------------------------+
| find_in_set('mysql','oracle,sql server,mysql,db2') |
+----------------------------------------------------+
|                                                  3 |
+----------------------------------------------------+
1 row in set (0.00 sec)

field

mysql> help field
Name: 'FIELD'
Description:
Syntax:
FIELD(str,str1,str2,str3,...)

Returns the index (position) of str in the str1, str2, str3, ... list.
Returns 0 if str is not found.

If all arguments to FIELD() are strings, all arguments are compared as
strings. If all arguments are numbers, they are compared as numbers.
Otherwise, the arguments are com
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄宝康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值