How do you extract the last three characters of varying-length file IDs?
A negative substr start counts backward from the end. Positions in text are measured in characters.
SQLite example and interpretation
The last three characters of run-017 are the text 017. Converting to integer discards the leading zero needed for a fixed-width identifier.
SELECT substr('run-017',-3);Result [["017"]]
中文
文件编号长度不一时怎样提取末三位?
substr 的负起点从字符串末尾向前数。文本参数以字符位置计数。
SQLite 示例与适用条件
run-017 的末三位仍是字符串 017。若转为整数就会丢掉前导零,不适合作固定宽度编号。
SELECT substr('run-017',-3);结果 [["017"]]