HSQLDB LIKE查询因sharp-s而失败

时间:2013-07-11 11:49:08

标签: hsqldb sql-like

我无法在不区分大小写的文本字段中为包含德语sharp-s(ß)的字段编写有效的LIKE查询。

使用HSQLDB 2.2.9,创建一个包含区分大小写字段和不区分大小写字段的表。

CREATE CACHED TABLE MYTABLE (MYKEY LONGVARCHAR NOT NULL, PRIMARY KEY (MYKEY));
ALTER TABLE MYTABLE ADD COLUMN SEN LONGVARCHAR;
ALTER TABLE MYTABLE ADD COLUMN INSEN VARCHAR_IGNORECASE;

写2条记录。

INSERT INTO MYTABLE (MYKEY, SEN, INSEN) VALUES ('1', 'Strauß', 'Strauß');
INSERT INTO MYTABLE (MYKEY, SEN, INSEN) VALUES ('2', 'Strauss', 'Strauss');

验证

SELECT * FROM MYTABLE
KEY, SEN,       INSEN
'1', 'Strauß',  'Strauß'
'2', 'Strauss', 'Strauss'

问题查询:

SELECT * FROM MYTABLE WHERE INSEN LIKE '%ß%'
WRONG, RETURNS RECORD 2 NOT RECORD 1

这些查询按预期工作:

SELECT * FROM MYTABLE WHERE SEN LIKE '%ß%'
OK, RETURNS RECORD 1

SELECT * FROM MYTABLE WHERE UCASE(INSEN) LIKE '%ß%'
OK, RETURNS RECORDS 1 AND 2

SELECT * FROM MYTABLE WHERE UCASE(SEN) LIKE '%ß%'
OK, RETURNS NOTHING

SELECT * FROM MYTABLE WHERE SEN='Strauß'
OK, RETURNS RECORD 1

SELECT * FROM MYTABLE WHERE INSEN='Strauß'
OK, RETURNS RECORD 1

SELECT * FROM MYTABLE WHERE SEN='Strauss'
OK, RETURNS RECORD 2

SELECT * FROM MYTABLE WHERE INSEN='Strauss'
OK, RETURNS RECORD 2

谢谢!

0 个答案:

没有答案