sql MySQL中的instr()和locate()有什么区别?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql MySQL中的instr()和locate()有什么区别?相关的知识,希望对你有一定的参考价值。
/* MySQL */
select
tags,
instr(tags, 'TED'),
locate('TED', tags),
locate('TED', tags, 5),
instr(tags, 'ted'),
locate('ted', tags),
locate('ted', tags, 5),
instr(tags, 'TED%'),
locate('TED%', tags),
locate('TED%', tags, 5)
from datageeking.ted_talks
/*
tags |instr(tags, 'TED') |locate('TED', tags) |locate('TED', tags, 5) |
----------------------------------------------|-------------------|--------------------|-----------------------|
['children', 'creativity', 'culture', 'dance' |0 |0 |0 |
['alternative energy', 'cars', 'climate chang |0 |0 |0 |
['computers', 'entertainment', 'interface des |0 |0 |0 |
['MacArthur grant', 'activism', 'business', ' |0 |0 |0 |
['Africa', 'Asia', 'Google', 'demo', 'economi |0 |0 |0 |
['business', 'culture', 'entertainment', 'goa |0 |0 |0 |
['Christianity', 'God', 'atheism', 'comedy', |0 |0 |0 |
['architecture', 'collaboration', 'culture', |0 |0 |0 |
['God', 'TED Brain Trust', 'atheism', 'brain' |10 |10 |10 |
['Christianity', 'God', 'culture', 'happiness |0 |0 |0 |
['activism', 'architecture', 'collaboration', |0 |0 |0 |
['TED Prize', 'art', 'culture', 'entertainmen |3 |3 |0 |
['TED Prize', 'collaboration', 'disease', 'eb |3 |3 |0 |
['demo', 'design', 'interface design', 'techn |0 |0 |0 |
['children', 'design', 'education', 'entrepre |0 |0 |0 |
tags |instr(tags, 'ted') |locate('ted', tags) |locate('ted', tags, 5) |
----------------------------------------------|-------------------|--------------------|-----------------------|
['children', 'creativity', 'culture', 'dance' |0 |0 |0 |
['alternative energy', 'cars', 'climate chang |0 |0 |0 |
['computers', 'entertainment', 'interface des |0 |0 |0 |
['MacArthur grant', 'activism', 'business', ' |0 |0 |0 |
['Africa', 'Asia', 'Google', 'demo', 'economi |0 |0 |0 |
['business', 'culture', 'entertainment', 'goa |0 |0 |0 |
['Christianity', 'God', 'atheism', 'comedy', |0 |0 |0 |
['architecture', 'collaboration', 'culture', |0 |0 |0 |
['God', 'TED Brain Trust', 'atheism', 'brain' |10 |10 |10 |
['Christianity', 'God', 'culture', 'happiness |0 |0 |0 |
['activism', 'architecture', 'collaboration', |0 |0 |0 |
['TED Prize', 'art', 'culture', 'entertainmen |3 |3 |0 |
['TED Prize', 'collaboration', 'disease', 'eb |3 |3 |0 |
['demo', 'design', 'interface design', 'techn |0 |0 |0 |
['children', 'design', 'education', 'entrepre |0 |0 |0 |
tags |instr(tags, 'TED%') |locate('TED%', tags) |locate('TED%', tags, 5) |
----------------------------------------------|--------------------|---------------------|------------------------|
['children', 'creativity', 'culture', 'dance' |0 |0 |0 |
['alternative energy', 'cars', 'climate chang |0 |0 |0 |
['computers', 'entertainment', 'interface des |0 |0 |0 |
['MacArthur grant', 'activism', 'business', ' |0 |0 |0 |
['Africa', 'Asia', 'Google', 'demo', 'economi |0 |0 |0 |
['business', 'culture', 'entertainment', 'goa |0 |0 |0 |
['Christianity', 'God', 'atheism', 'comedy', |0 |0 |0 |
['architecture', 'collaboration', 'culture', |0 |0 |0 |
['God', 'TED Brain Trust', 'atheism', 'brain' |0 |0 |0 |
['Christianity', 'God', 'culture', 'happiness |0 |0 |0 |
['activism', 'architecture', 'collaboration', |0 |0 |0 |
['TED Prize', 'art', 'culture', 'entertainmen |0 |0 |0 |
['TED Prize', 'collaboration', 'disease', 'eb |0 |0 |0 |
['demo', 'design', 'interface design', 'techn |0 |0 |0 |
['children', 'design', 'education', 'entrepre |0 |0 |0 |
*/
以上是关于sql MySQL中的instr()和locate()有什么区别?的主要内容,如果未能解决你的问题,请参考以下文章