MySQL中等效的PHP stripos()是什么?
stripos()
MySQL中的等效项是INSTR()
,它返回一个字符串在另一个字符串中首次出现的位置。以下是语法-
select instr(yourColumnName,yourWord) As anyAliasName from yourTableName;
让我们首先创建一个表-
mysql> create table DemoTable-> (
-> Title text
-> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('MySQL is my favourite subject');mysql> insert into DemoTable values('MongoDB is not my favourite subject');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出
+-------------------------------------+| Title |
+-------------------------------------+
| MySQL is my favourite subject |
| MongoDB is not my favourite subject |
+-------------------------------------+
2 rows in set (0.00 sec)
这是查询以获取stripos()
MySQL中的等效项,并返回字符串的首次出现位置-
mysql> select instr(Title,'favourite') As Position from DemoTable;
输出结果
+----------+| Position |
+----------+
| 13 |
| 19 |
+----------+
2 rows in set (0.00 sec)
以上是 MySQL中等效的PHP stripos()是什么? 的全部内容, 来源链接: utcz.com/z/338359.html