The ||
operator is "concatenate" - it joins together the two strings of its operands.
सराहना की जाएगी से http://www.sqlite.org/lang_expr.html
गद्दी के लिए, उचित रूप में-बेईमान तरह से मैं आपके लक्ष्य स्ट्रिंग से शुरू करना है, '0000' कहें, '0000423' को संयोजित करें, फिर '0423' के लिए सबस्ट्र (परिणाम, -4, 4)।
अद्यतन: लगता है "lpad" या "rpad" SQLite में की कोई मूल कार्यान्वयन है की तरह है, लेकिन आप के साथ (मूल रूप से मैं क्या प्रस्तावित) यहाँ का पालन कर सकते हैं: http://verysimple.com/2010/01/12/sqlite-lpad-rpad-function/
-- the statement below is almost the same as
-- select lpad(mycolumn,'0',10) from mytable
select substr('0000000000' || mycolumn, -10, 10) from mytable
-- the statement below is almost the same as
-- select rpad(mycolumn,'0',10) from mytable
select substr(mycolumn || '0000000000', 1, 10) from mytable
यहां बताया गया है यह दिखता है:
SELECT col1 || '-' || substr('00'||col2, -2, 2) || '-' || substr('0000'||col3, -4, 4)
यह पैदावार
"A-01-0001"
"A-01-0002"
"A-12-0002"
"C-13-0002"
"B-11-0002"
संभावित डुप्लिकेट: http://stackoverflow.com/q/3568779/2291 –