SQLite 查询区分大小写 [英] SQLite query case sensitive
问题描述
我在 SQLite 中有一个包含几列的表.我有两列需要用于查询此表(代码、描述).创建表时,这两个都有COLLATE NOCASE
,如下所示:
I have a table with few columns in SQLite. I have two columns that I need to use for querying this table (code, Description). Both of these have the COLLATE NOCASE
when creating the tables as below:
CREATE TABLE [AuditEvent] (
"Code" char(4) NOT NULL COLLATE NOCASE,
"Description" nvarchar(255) NOT NULL COLLATE NOCASE,
"AuditEventPK" guid NOT NULL,
PRIMARY KEY ([Code])
);
当我使用代码查询表时,我没有得到任何结果
When I query the table using the code I get no results
select * from auditevent where code = 'add' -- does not return any value
select * from auditevent where description = 'add' -- returns the right record.
但是,当我使用描述 colomun 查询表时,我得到了结果.
However when I query the table using the description colomun, I get the results.
在某些情况下,我必须使用 CODE,但它没有返回任何内容.有什么想法吗??
In some cases, I have to use the CODE, but it is not returning anything. Any idea??
推荐答案
看来我需要使 CODE
列的类型为 varchar
而不是 char
正如 Silvermind 所解释的那样.谢谢 Silvermind.
It appeared that I need to make the CODE
column of type varchar
instead of char
as Silvermind explained. Thanks Silvermind.
这篇关于SQLite 查询区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!