This shows you the differences between two versions of the page.
dev:sql:functions:position [2010/07/02 08:25] tdo |
dev:sql:functions:position [2016/06/28 22:38] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | {{page>:top_add&nofooter&noeditbtn}} | ||
- | <html><div align="center"><span style="color:red">DRAFT</span></div></html> | ||
- | ====== Omnidex SQL Function: POSITION ====== | ||
- | {{page>:sql_bar&nofooter&noeditbtn}} | ||
- | ===== Description ===== | ||
- | Find the position of string1 in string2. The POSITION function returns the position of a string (string1) within another string (string2). If string2 is of length zero, the result is 1. If string1 occurs as a substring within string2, the character position where string1 first occurs is returned. If neither of these conditions is true, the result is 0. The return data type is a 4-byte INTEGER. | ||
- | String comparisons are case-sensitive. Use the UPPER and LOWER functions around string1 and string2 to produce a case-insensitive search. | ||
- | ===== Syntax ===== | ||
- | POSITION( search_string IN target_string) | ||
- | |||
- | == search_string === | ||
- | Any valid text string enclosed in single quotes or a column_spec or an expression such as a function that resolves to a text string. The search_string is the string of interest that is being search for in the target_string. | ||
- | |||
- | == IN == | ||
- | Required. | ||
- | |||
- | == target_string == | ||
- | Any column_spec or valid text string enclosed in single quotes or an expression such as a function that resolves to a text string. The target_string in which to search for the occurance of the search_string. | ||
- | |||
- | ===== Example ===== | ||
- | ==== Example 1 ==== | ||
- | <code SQL> | ||
- | select company, | ||
- | position(upper('sys') IN upper(customers.company)) | ||
- | from customers where company='systems' | ||
- | |||
- | Company Position | ||
- | -------- --------------- | ||
- | Camco Systems 7 | ||
- | SoftSys Corp 5 | ||
- | |||
- | </code> | ||
- | {{page>:bottom_add&nofooter&noeditbtn}} |