English 中文(简体)
案件不敏感搜查/检查
原标题:Case Insensitive searches/queries

是否有任何人知道如何用“邮资”进行不敏感的搜查/ery?

我在思考一下是遗憾的,但我不敢肯定如何做,或者也许有某种职能/滞后,或者我可以补充什么?

I m using PHP to connect and execute the queries.

因此,我期望与信息相匹配。

例:

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% 

Documentation。


或者,您可使用<编码>UPPER或LOWER,例如:

...
WHERE 
    LOWER(address) LIKE  123 main st% 
问题回答

除了ILIKE和较低的()办法外,我还可以看到另外两种可能性:

  1. Use the citext data type: http://www.postgresql.org/docs/9.0/static/citext.html.
  2. Use the full text search - which might actually be the most flexible and fastest solution, although a bit more complicated to get started with.




相关问题
摘录数据

我如何将Excel板的数据输入我的Django应用? I m将PosgreSQL数据库作为数据库。

Postgres dump of only parts of tables for a dev snapshot

On production our database is a few hundred gigabytes in size. For development and testing, we need to create snapshots of this database that are functionally equivalent, but which are only 10 or 20 ...

How to join attributes in sql select statement?

I want to join few attributes in select statement as one for example select id, (name + + surname + + age) as info from users this doesn t work, how to do it? I m using postgreSQL.

What text encoding to use?

I need to setup my PostgreSQL DB s text encoding to handle non-American English characters that you d find showing up in languages such as German, Spanish, and French. What character encoding should ...

SQL LIKE condition to check for integer?

I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A": SELECT * ...

热门标签