惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 狼问苍穹

php图片、文件上传 怎样推广自己的博客 nfs文件系統 重新来过! 网站被挂iframe木马的解决方案 PHP公历农历转换(阴历阳历转换)阴历和阳历转换 去掉fck里的图片 js 对FCKeditor 进行是否为空验证 Zend studio 打开 utf-8 出现乱码之解决办法 解决HTML内部元素的Mouse事件干扰(实例,兼容ff,ie) JavaScript事件监听完整实例 兼容IE、Firefox的DIV透明 阻止JavaScript事件冒泡传递 date picker plugin - jQuery 用法 Transact-SQL语句总汇(转载) 建一个临时表 php数组总结资料 js获取url参数 smarty date_format 产生乱码??
mysql截取函数LOCATE和POSITION
狼问苍穹 · 2009-02-23 · via 博客园 - 狼问苍穹

在mysql 里是没有像sqlserver的charindex函数的, 用LOCATE和POSITION函数可以实现功能!

LOCATE(substr,str)
POSITION(substr IN str)
返回子串 substr 在字符串 str 中第一次出现的位置。如果子串 substr 在 str 中不存在,返回值为 0:
mysql> SELECT LOCATE(’bar’, ‘foobarbar’);
-> 4
mysql> SELECT LOCATE(’xbar’, ‘foobar’);
-> 0

这个函数是多字节安全的。在 MySQL 3.23 中,这个函数是字母大小写敏感的,当在 MySQL 4.0 中时,如有任一参数是一个二进制字符串,它才是字母大小写敏感的。

LOCATE(substr,str,pos)
返回子串 substr 在字符串 str 中的第 pos 位置后第一次出现的位置。如果 substr 不在 str 中返回 0 :
mysql> SELECT LOCATE(’bar’, ‘foobarbar’,5);
-> 7

这个函数是多字节安全的。在 MySQL 3.23 中,这个函数是字母大小写敏感的,当在 MySQL 4.0 中时,如有任一参数是一个二进制字符串,它才是字母大小写敏感的。

综合例子:

select info.* from info left join attribute as a on POSITION(CONCAT(substr('00000',1,5-LENGTH(info.fid)),info.fid) IN a.fid) <>0