要查找某个指定的字符在字符串中出现的位置,方法比较简单,使用 len() 函数和 replace() 函数结合就可以. SELECT TOP 200 approveInfo approveInfo2, LEN(approveInfo)-LEN(REPLACE(approveInfo,';','')) AS appLen, * FROM dbo.Log_Year WHERE ISNULL(approveInfo,'')<>'' ORDER BY appLen DESC 原理:字符串的长度 减去…
公司发了一张面试题给我,题目如下: 在test数据库中有个flow_user表,找出email字段中@之前字符相同且大于等于2条的所有记录 答案: select substring_index(`email`,'@',1) as email,count(*) as count from flow_user group by email having count>=2;…