Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dev:sql:functions:substring [2009/12/05 00:41]
tdo
dev:sql:functions:substring [2012/10/26 14:28] (current)
Line 4: Line 4:
 {{page>:​sql_bar&​nofooter&​noeditbtn}} {{page>:​sql_bar&​nofooter&​noeditbtn}}
 ===== Description ===== ===== Description =====
-The SUBSTRING function returns a new character string that is a substring ​of another string. The new string begins at the specified starting point in the original string ​(string1) ​and extends the number of characters specified in the length parameter. If the length parameter is omitted, the new string extends to the end of the original string.+The SUBSTRING function returns a new character string that is a portion ​of another ​column or string. ​ 
 + 
 +The new string begins at the specified starting point in the original ​column or string and extends the number of characters specified in the length parameter. If the length parameter is omitted, the new string extends to the end of the original string.
  
 The return data type is C STRING. The return data type is C STRING.
Line 11: Line 13:
  
 == < column_spec | '​string'​ >== == < column_spec | '​string'​ >==
 +Required. This is the optionally database.table qualified column or string literal enclosed in single quotes that contains the characters that will be returned.
  
-Required. This is the string that contains the characters that will be returned.+== FROM start_no ==
  
-== FROM ==+Required. The FROM start_no is a number indicating the number of characters where in the column or string to start the extraction of the partial string. ​ The start_no ​
  
-The FROM keyword is required.+^ String ^  | M | y |   | s |  t | r | i | n | g | 
 +^Position ^ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
  
-== start_no ​== +If the start_no ​was 4 in the string above, then '​s'​ would be the first character ​of the returned ​substring.
- +
-Required. start is an integer indicating ​the position of the first character ​relative to 1 that will be returned.+
  
 == FOR length == == FOR length ==
  
 Optional. This indicates the number of characters after and including the start character, that will be returned. If omitted, all of the remaining characters after and including the start character will be returned. Optional. This indicates the number of characters after and including the start character, that will be returned. If omitted, all of the remaining characters after and including the start character will be returned.
 +
 ===== Example ===== ===== Example =====
-==== Example 1 ====+==== Example 1: Substring of column ​====
 <code SQL> <code SQL>
-select product_no,+  > select product_no,
 SUBSTRING(PRODUCTS.PRODUCT_NO FROM 2 FOR 3) as Sub1,  SUBSTRING(PRODUCTS.PRODUCT_NO FROM 2 FOR 3) as Sub1, 
 SUBSTRING(PRODUCTS.PRODUCT_NO FROM 5) as Sub2 SUBSTRING(PRODUCTS.PRODUCT_NO FROM 5) as Sub2
Line 37: Line 40:
  ​ASUP93541 ​        ​SUP ​       93541  ​ASUP93541 ​        ​SUP ​       93541
  ​BPRI54687 ​        ​PRI ​       54687  ​BPRI54687 ​        ​PRI ​       54687
 +</​code>​
 +==== Example 2: Substring of '​string'​ ====
 +<code SQL>
 +  > SELECT SUBSTRING ('My String'​ from 4) from $omnidex
  
 +SUBSTR
 +------
 +String
 </​code>​ </​code>​
  
  
 {{page>:​bottom_add&​nofooter&​noeditbtn}} {{page>:​bottom_add&​nofooter&​noeditbtn}}
 
Back to top
dev/sql/functions/substring.1259973704.txt.gz · Last modified: 2012/10/26 14:27 (external edit)