Notice (8): file_put_contents(): Write of 270 bytes failed with errno=28 No space left on device [CORE/src/Log/Engine/FileLog.php, line 140]

Notice: file_put_contents() [function.file-put-contents]: Write of 1108 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5131 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3153 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): SplFileObject::fwrite() [<a href='https://secure.php.net/splfileobject.fwrite'>splfileobject.fwrite</a>]: Write of 5437 bytes failed with errno=28 No space left on device [CORE/src/Cache/Engine/FileEngine.php, line 141]

Notice: file_put_contents() [function.file-put-contents]: Write of 3153 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 90093 of 90101 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2491 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
Notice (8): unserialize() [<a href='https://secure.php.net/function.unserialize'>function.unserialize</a>]: Error at offset 94197 of 94197 bytes [APP/Controller/NewsController.php, line 5571]

Notice: file_put_contents() [function.file-put-contents]: Write of 2491 bytes failed with errno=28 No space left on device in /www/wwwroot/www.adminso.com/vendor/cakephp/cakephp/src/Log/Engine/FileLog.php on line 140
SqlServer英文单词全字匹配详解及实现代码 - 站长搜索
首页 > 资讯列表 > 编程/数据库 >> 数据库操作教程

SqlServer英文单词全字匹配详解及实现代码

数据库操作教程 2022-09-23 16:43:59 转载来源: 网络整理/侵权必删

SqlServer英文单词全字匹配环境:Vs2013+SqlServer2012问题:现在数据库记录如下: Sentence列保存的是英文的句子,我现在想找出所有包含“I”(单词)的句子,如果我用Sentencelike'%I',作为条件的话,那么像上图选中的那条有个单词“it“(不区分大小写的情况下),它也会被Select出来,而我只想找出含有“I”这个单词的句子的记录。解决:SqlServer提供了模式匹配,类似于正则,详细内容查阅相关文档

SqlServer英文单词全字匹配

环境:Vs2013+Sql Server2012

问题:现在数据库记录如下:

 

Sentence列保存的是英文的句子,我现在想找出所有包含“I”(单词)的句子,如果我用 Sentence like '%I',作为条件的话,那么像上图选中的那条有个单词“it“(不区分大小写的情况下),它也会被Select出来,而我只想找出含有“I”这个单词的句子的记录。

解决:SqlServer提供了模式匹配,类似于正则,详细内容查阅相关文档。

我先写了一个这样的条件:

Sentence like '%[^a-zA-Z]I[^a-zA-Z]%'

发现上图里的第一条,也就是“I would...",“I”开头的单词没有被Select出来,也就是说,这个条件所匹配的是前面要一个非字母的符号(没有字符是不可以的),那么同样道理,最后面也需要一个非字母的符号(没有字符也是不可以的),所以可改成:

Sentence like '%[^a-zA-Z]I[^a-zA-Z]%' or Sentence like 'I[^a-zA-Z]%' or Sentence like '%[^a-zA-Z]I'

不过感觉这样比较麻烦,如果把Sentence前后各加一个非字母的数字,像原本“I would like I",把它变成“   I would like I  "(前后各加一个空格),这样就能匹配最开始写的那个条件了:

' '+Sentence+' ' like '%[^a-zA-Z]I[^a-zA-Z]%'

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

标签: SqlServer 英文 单词 全字 匹配 详解 实现 代码


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2025 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持