我有一个简单的SQL查询,可在其中帮助我找到值,字段文本中包含一些英文字母。
这里的SQL:
select id,field1
from mytable
where mytable like '[A-Z]'
该查询在MS-ACCESS数据库中运行良好,但不适用于QGIS和postgis查询上的DB MANAGER,因为我认为Postgres无法识别字母列表[AZ]。
如果我使用这个:
select id,field1
from mytable
where mytable like '%A%'
or mytable like '%B%'......
那就行了,但我不喜欢这种方法。
在Postgres中:
select public.mytable.id,public.mytable.field1
from mytable
where public.mytable.mytable like '[A-Z]'
我尝试使用:
'*[A-Z]*'
'%[A-Z]%'
但这并没有改变任何东西
在postgres中,有波浪号运算符用于将字符串与正则表达式匹配
select * from some_table where some_column ~ '^[A-Z]$'
将选择some_column
仅包含大写字母的记录。也~*
用于不区分大小写的比较。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句