在我用來排序的地方運行 SQLiteselect查詢:order by tagTitle COLLATE NOCASE ASC
$ echo 'select tagTitle from tags where bookName = "Dragons" order by tagTitle COLLATE NOCASE ASC ' | sqlite3 /tmp/IndexerSqlite.db |awk {'print substr($1,0,1)'} |uniq -c
1 &
3 -
2 .
2 /
1 1
1 ;
1 @
1 a
5 A
2 a
...
3 W
4 X
1 x
1 X
1 Z
4 | <<--- This!
|位于底部。其他地方|的優先級更高:
$ echo "a
b
|
c
$
."|sort
.
| // <<-- this!
$
a
b
c
我怎樣才能在|不是最后的地方按常規順序獲得結果?
復制:
$ sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table test("name" blob);
sqlite> insert into test (name) values (".csdcdsc");
sqlite> insert into test (name) values ("XACDSC");
sqlite> insert into test (name) values ("ACDSC");
sqlite> insert into test (name) values ("CDSC");
sqlite> insert into test (name) values ("|CDSC");
sqlite> select * from test order by name COLLATE NOCASE ASC;
.csdcdsc
ACDSC
CDSC
XACDSC
|CDSC << --This
sqlite>
uj5u.com熱心網友回復:
Sqlite 按代碼點按字典順序對字串進行排序。管道是U 007C,放在英文字母和一堆其他符號之后。sort(1)根據當前語言環境的規則進行排序;您可能正在使用一個用標點符號和符號做一些花哨的東西。切換到一個也使用普通字典順序的,然后......
echo "a
b
|
c
$
." | LC_ALL=C sort
$
.
a
b
c
|
您必須撰寫和加載定義新排序順序的Sqlite 擴展模塊。這有多容易取決于你對 C 的了解程度。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/529247.html
上一篇:按日期將CSV檔案匯入資料庫
