經常會遇見欄位中存的是帶有網頁元素的字串,怎麼取出純文字呢?
方法如下:
使用函式fnstriptags
set global log_bin_trust_function_creators=1;
drop function if exists fnstriptags;
create function fnstriptags( dirty text(0) )
returns text(0)
deterministic
begin
declare istart, iend, ilength int;
while locate( ' 0 and locate( '>', dirty, locate( ' 0 do
begin
set istart = locate( '', dirty, locate('
set ilength = ( iend - istart) + 1;
if ilength > 0 then
begin
set dirty = insert( dirty, istart, ilength, '');
end;
end if;
end;
end while;
return dirty;
end;
使用方式
例:未使用前
使用函式後:
mysql 匯出資料
方法一 select.into outfile mysql select from mytbl into outfile tmp mytbl.txt 檢視mytbl.txt中內容如下 mysql system cat tmp mytbl.txt1 name1 2 name2 3 n 匯出的檔案中資料...
MySQL資料匯出
方法一 select.into outfile mysql select from mytbl into outfile tmp mytbl.txt query ok,3 rows affected 0.00 sec 檢視mytbl.txt中內容如下 mysql system cat tmp myt...
MySql資料匯出
mysql use caida 選擇要操作的資料庫 mysql select ip,node,physical cpu,cpu cores,processor,cpumodel,throughtput,use processor,use memory,use disk from three open...