mysql regexp正则表达式

发布:2014-01-27 11:32   点击1128次   评论:0

http://blog.sina.com.cn/s/blog_71261a2d0100wzk9.html
mysql regexp正则表达式


where concat(',',hobby,',') regexp 
    ->   concat(',(',replace('阅读,交友,围棋,足球,滑雪',',','|'),'),'); 


CONCAT(',',REPLACE(fwpt,' ',','),',') REGEXP
CONCAT(',(',replace('12,13,14,15',',','|'),'),');


SELECT fwpt FROM cms_archives_3 a
WHERE CONCAT(' ',a.fwpt,' ') LIKE '% 12 %'
OR CONCAT(' ',a.fwpt,' ') LIKE '% 13 %'
OR CONCAT(' ',a.fwpt,' ') LIKE '% 14 %'
OR CONCAT(' ',a.fwpt,' ') LIKE '% 15 %'
LIMIT 200; 

SELECT fwpt FROM cms_archives_3 a
WHERE CONCAT(' ',a.fwpt,' ') LIKE '% 12 %'
OR CONCAT(' ',a.fwpt,' ') LIKE '% 13 %'
OR CONCAT(' ',a.fwpt,' ') LIKE '% 14 %'
LIMIT 200; 


----------------------------- 

SELECT fwpt FROM cms_archives_3 
WHERE fwpt REGEXP '^(12)$|^(12)\t|\t(12)\t|\t(12)$'
LIMIT 200; 

SELECT fwpt FROM cms_archives_3 a
WHERE CONCAT(' ',a.fwpt,' ') LIKE '% 12 %'
LIMIT 200; 

----------------------------- 
//以下行,可替代foreach,但效率差不多
//$this->searchstr = "CONCAT(',',REPLACE($fpre$fn,'\t',','),',') REGEXP CONCAT(',(',replace('".implode(',',${$fn})."',',','|'),'),')";


----------------------------- 


关于 GitHub 导航 部门 反馈

提示:`/home.php`入口数据仅为演示功能,不构成任何交易凭证,也不承担相关风险和责任!

Copyright © 2011-2018 xxxxx.com All rights reserved.

Run:18.789/51.861(ms); 7(sql)/2.877(MB); comm:news/detail; Upd:2025-01-11 05:02:31