不区分大小写的搜索/查询 [英] Case Insensitive searches/queries

查看:141
本文介绍了不区分大小写的搜索/查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何使用Postgres 7.4进行不区分大小写的搜索/查询吗?

Does anyone know how to do a Case Insensitive Search/Query with Postgres 7.4?

我在考虑RegEx,但不确定如何执行此操作,或者可能有一个函数/标志还是可以添加查询的内容?

I was thinking RegEx but not sure how to do this or maybe there is a function/flag or something I could add the the query?

我正在使用PHP连接并执行查询。

I'm using PHP to connect and execute the queries.

所以我要匹配地址信息。

So I'm looking to match address information.

示例:

123 main street
123 Main st.
123 Main Street
123 main st
123 Main st
etc...

有什么想法吗?

SELECT address FROM tbl WHERE address LIKE '%123 %ain%'


推荐答案

使用 ILIKE ,例如:

...
WHERE 
    address ILIKE '123 main st%'

文档

或者,您可以使用 UPPER LOWER ,例如:

Alternatively you could use UPPER or LOWER, e.g.:

...
WHERE 
    LOWER(address) LIKE '123 main st%'

这篇关于不区分大小写的搜索/查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆