1.首先遇到這個需求比較冷門所以特地在此記錄下
第一步、建立儲存過程
set
global log_bin_trust_function_creators=1;
drop
function
ifexists fnstriptags;
delimiter
|create
function fnstriptags( dirty text(0
))returns
text(0
)deterministic
begin
declare istart, iend, ilength int
;while locate(
'<'
, dirty )
>
0and locate(
'>'
, dirty, locate(
'<'
, dirty )
)>0do
begin
set istart = locate(
'<'
, dirty )
, iend = locate(
'>'
, dirty, locate(
'<'
, dirty ));
set ilength =
( iend - istart)+1
;if ilength >
0then
begin
set dirty =
insert
( dirty, istart, ilength,'')
;end
;endif;
end;
endwhile
;return dirty;
end;
|delimiter
;
第二步、引用該函式即可,因為本人在此只用到查詢需求,如果有用到更新或其他操作的希望大家自行嘗試。
select fnstriptags(content)
,create_time
第三步、去除
select
replace
(fnstriptags(content)
,' ',''
),create_time
2.最後整兩句
好長時間沒更博了看來還是太懶了,沒事的時候還是應該多完善完善部落格和多寫一些新博來拓寬自己,感謝網友的支援。最後說下臨近春節,希望廣大碼農和全國網友能回去的和因疫情不能回的都能過個好年。疫情無情,但人間有愛。克服疫情,共創時堅。
3.參考部落格
mysql中去除重複字段 distinct
今天在進行資料處理的時候需要去除重複的資料,使用distinct十分便捷,所以做一下說明。1 注意事項 使用distinct命令時需要放在查詢條件的開頭,否則會報錯。如果需要查詢的專案很多但只針對某乙個字段使用distinct的,則可以利用內容拼接的方式來實現。2 一般用法 以下為使用的基礎資料表 ...
去除富文字中的標籤
從資料庫獲取富文字string string data content 把一些預定義的 html 實體轉換為字元 html string htmlspecialchars decode string 將空格替換成空 content str replace html string 函式剝去字串中的 h...
mySql 文字字段長度
blob text 乙個blob或text列,最大長度為65535 2 16 1 個字元。mediumblob mediumtext 乙個blob或text列,最大長度為16777215 2 24 1 個字元。longblob longtext 乙個blob或text列,最大長度為429496729...