工作在PostgreSQL 8,为什么这是确定“LIKE” 并不如预期
select * from prod where code like '1%'
select * from prod where code like '%1'
但这返回0行(有码begining /用数字1结尾)
select * from prod where code like '1%1'
更新
这发生在我目前的安装目录:
# psql --version
psql (PostgreSQL) 8.3.7
create table a(code char(10));
CREATE TABLE
db=# insert into a values('111');
INSERT 0 1
db=# select * from a where code like '1%';
code
------------
111
(1 row)
db=# select * from a where code like '%1';
code
------
(0 rows)
db=# select * from a where code like '1%1';
code
------
(0 rows)
更新2
它是数据类型!用varchar它是好的!
谢谢。
你可能想编辑你的问题 - 我不明白。如果postgres没有在你的查询中显示代码为“111”的数据,那么有些事情会被破坏,但说实话 - 我真的不相信它。向我们显示数据,查询,收到结果和预期结果。 – 2009-10-09 11:17:20