msql以某个字符串开头条件查询,除了like替代方式

1:以字段开头模糊查询的like的方法查询

select * from t where t.user_code like 'A%'

2:以字段开头模糊查询的left(字段,长度)的方法查询

select * from t where left(t.user_code, 1)='A';

3:字符间隔查询段对应的值以 1,4,6 的格式查询使用find_in_set

select * from t where FIND_IN_SET('1',t.name);//t.name所查询的字段,所有包含1的数据

4:LOCATE('参数',字段) 例如:select*from table where locate("参数",字段)

posted @ 2022-06-02 16:28  WPMA  阅读(938)  评论(0编辑  收藏  举报