1

我无法在不区分大小写的文本字段中为包含德语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

谢谢!

4

0 回答 0