久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL中substring

131次閱讀
沒有評論

共計 1188 個字符,預計需要花費 3 分鐘才能閱讀完成。

自動寫代碼機器人,免費開通

本篇文章為大家展示了 MySQL 中 substring_index 函數的作用是什么,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

MySQL 的 substring_index 函數簡析
 
假定有一張表,其中有個字段是 email 保存了電子郵箱,然后,我想統計每種郵箱的占比情況。
我們知道電子信箱的格式是:account@domain,要實現上面的統計,必須取得 email
字符串中 @ 后面的域名部分。
MySQL 提供了一個名為 substring_index 的函數,能夠滿足我們的需求:
MySQL 5.5 Reference Manual 寫道  www.2cto.com  
SUBSTRING_INDEX(str,delim,count)
 
Returns the substring from string str before count occurrences of the delimiter delim.
If count is positive, everything to the left of the final delimiter (counting from the left)
is returned. If count is negative, everything to the right of the final delimiter (counting
from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when
searching for delim.
 
SELECT SUBSTRING_INDEX(www.mysql.com , . , 2);
 
        – www.mysql
 
mysql SELECT SUBSTRING_INDEX(www.mysql.com , . , -2);
 
        – mysql.com
 
This function is multi-byte safe. 
   www.2cto.com  
查詢語句如下:
Sql 代碼  
select  
    substring_index(email, @ ,-1) as domain,  
    count(distinct email) as count,  
    count(distinct email)  
        / (select count(distinct email) from qzt_resume_basic where email like %@% )  
        * 100 as percent  
from qzt_resume_basic  
where email like %@%  
group by 1  
order by 2 desc  
limit 10;  

上述內容就是 MySQL 中 substring_index 函數的作用是什么,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注丸趣 TV 行業資訊頻道。

向 AI 問一下細節

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-12-04發表,共計1188字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 曲水县| 福海县| 宾川县| 平舆县| 弥渡县| 江孜县| 古浪县| 永平县| 松溪县| 温泉县| 南平市| 大同县| 凤山县| 连平县| 安阳市| 巴中市| 沙河市| 海安县| 石棉县| 平罗县| 义马市| 揭东县| 乌苏市| 平乡县| 香河县| 石狮市| 汝南县| 夏邑县| 抚州市| 宁国市| 浏阳市| 淮滨县| 南通市| 西城区| 贡觉县| 北票市| 偏关县| 鲁甸县| 婺源县| 宣汉县| 溆浦县|