admin管理员组

文章数量:1487745

mysql 判断字符串结尾

mysql 判断字符串结尾

CREATE TABLE `tbl_str` ( `id` INT DEFAULT NULL, `Str` VARCHAR(30) DEFAULT NULL )

INSERT INTO `mytest`.`tbl_str` (`id`, `Str`) VALUES ('1', 'hello world'), ('2', 'mysql string'), ('3', 'hello');

##substring(str,pos,len) pos开始提取的位置,len提取的长度,pos如果为负数,则从字符串的末尾开始计算 SELECT id,str,SUBSTRING(str,-6) FROM `tbl_str`;

##从字符串的右侧提取指定长度的字符 SELECT id,str,RIGHT(str,6) FROM `tbl_str`;

##扩展 左侧 SELECT id,str,LEFT(str,6) FROM `tbl_str`; ##扩展 中部 SELECT id,str,MID(str,6) FROM `tbl_str`;

##like模式匹配,可以用来判断字符串的结尾。 SELECT id,str,str LIKE '%world' FROM `tbl_str`; # 匹配上了返回结果 1

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。 原始发表:2023-12-24,如有侵权请联系 cloudcommunity@tencent 删除defaultmysqlnullselect字符串

本文标签: mysql 判断字符串结尾