G
G
gsdev992019-11-01 14:29:39
PHP
gsdev99, 2019-11-01 14:29:39

How to properly configure sqlite so that LIKE works in Cyrillic?

Hello. Tell me, please, how to set it up correctly so that LIKE works in Cyrillic?
I am using sqlite3 in express.js project

CREATE TABLE people (
  pbnum INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
  pbfirstName VARCHAR(50) NOT NULL,
  pblastName VARCHAR(50) NOT NULL,
  pbcity VARCHAR(50) NOT NULL,
  pbphoneNumber VARCHAR(50) NOT NULL);


INSERT INTO people (pbfirstName, pblastName, pbcity, pbphoneNumber) VALUES
('user', 'one', 'Сочи', '+7 (111) 111-11-11'),
('user', 'two', 'Москва', '+7 (222) 222-22-22'),
('user', 'three', 'Москва', '+7 (333) 333-33-33'),
('user', 'four', 'Москва', '+7 (444) 444-44-44'),
('user', 'five', 'Москва', '+7 (555) 555-55-55');


SELECT * FROM people WHERE CONCAT (pbfirstName, pblastName, pbcity) LIKE "%со%"

'Sochi' in this case does not fall into the sample.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
santavits, 2018-09-18
@santavits

It did not work due to the fact that the ssl certificate was not connected.

V
Vitaly, 2018-09-18
@Anvi-Vt

What do the logs say?

Q
Quattro Vias, 2018-09-18
@Quattro_Vias

Check $txt - everything that goes into $api (for a link) should already be in the URL
To check, try entering "%D0%9F%D1%80%D0%B8%D0%B2%D0%B5%D1%82" instead of "$txt"
Or drop the full $api link for an example.

R
Roman Kitaev, 2019-11-01
@gsdev99

This is a well-known bug feature of sqlite. Do like this:
Cast both parts to the same case, then LIKE works. And since you still have a wildcard on both sides, you can still forget about using indexes, so it doesn’t change anything.
If the wildcard was only on one side, it would be possible to create a functional index

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question