Difference between revisions of "CONTAINS()"

From Lianjapedia
Jump to: navigation, search
 
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Function to perform a case-insensitive search of a record's character and memo (optional) fields for a specified character string
 
Function to perform a case-insensitive search of a record's character and memo (optional) fields for a specified character string
 
  
 
==Syntax==
 
==Syntax==
 
CONTAINS(<expC>,[<expL>|<expN>])
 
CONTAINS(<expC>,[<expL>|<expN>])
 
  
 
==See Also==
 
==See Also==
[[BETWEEN()]], [[CHROVERLAP()]], [[EMPTY()]], [[EVALUATE()]], [[EXPRCHECK()]], [[FOR()]], [[INDEX]], [[INLIST()]], [[INRANGE()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[LOWER()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[MTOS()]], [[PROPER()]], [[Relational Operators]], [[SEEK]], [[SEEK()]], [[TYPE()]], [[UPPER()]], [[VARTYPE()]]
+
[[BETWEEN()]], [[CHROVERLAP()]], [[EMPTY()]], [[EVALUATE()]], [[EXPRCHECK()]], [[FOR()]], [[HTML_TOPLAINTEXT()]], [[INDEX]], [[INLIST()]], [[INRANGE()]], [[ISALPHA()]], [[ISBLANK()]], [[ISDIGIT()]], [[LOWER()]], [[MAX()]], [[MAXVALUES()]], [[MIN()]], [[MINVALUES()]], [[MTOS()]], [[PROPER()]], [[SEEK]], [[SEEK()]], [[TYPE()]], [[UPPER()]], [[VARTYPE()]]
 
+
  
 
==Description==
 
==Description==
Line 16: Line 13:
 
A case-insensitive search is performed on the current record's character fields.  If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also checked, otherwise they are excluded from the search.   
 
A case-insensitive search is performed on the current record's character fields.  If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also checked, otherwise they are excluded from the search.   
  
 
+
{| class="wikitable" width="100%"
{| class="wikitable"
+
 
!Parameters||Description
 
!Parameters||Description
 
|-
 
|-
|<expC>||The character string to search for.
+
|<expC>||The character string to search for. Delimit words or phrases with commas
 
|-
 
|-
 
|<expL>||If .T. (True), memos are included in the search.
 
|<expL>||If .T. (True), memos are included in the search.
Line 27: Line 23:
 
|-
 
|-
 
|}
 
|}
 
  
 
The CONTAINS() function is particularly useful in creating full text-search indexes, as shown in the example below.
 
The CONTAINS() function is particularly useful in creating full text-search indexes, as shown in the example below.
 
  
 
==Example==
 
==Example==
Line 37: Line 31:
 
use products
 
use products
 
// Restrict index to product records in category 2 (condiments) with a character field containing string "bottled", memos excluded
 
// Restrict index to product records in category 2 (condiments) with a character field containing string "bottled", memos excluded
index on lower(productname) for contains("bottles",.F.) and categoryid = 2 tag bottled
+
index on lower(productname) for contains("bottles,jars,cans",.F.) and categoryid = 2 tag bottled
 
</code>
 
</code>
  
 
==Products==
 
Recital Server, Recital
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
[[Category:Expressions and Type Conversion]]
+
[[Category:Formatting Functions]]
[[Category:Expressions and Type Conversion Functions]]
+
[[Category:Cursor Functions]]
[[Category:Indexing]]
+
[[Category:Memos Functions]]
[[Category:Indexing Functions]]
+
[[Category:Search Functions]]
 +
[[Category:Lianja VFP Extensions]]
 +
[[Category:VFP Function Extensions]]

Latest revision as of 09:25, 20 September 2016

Purpose

Function to perform a case-insensitive search of a record's character and memo (optional) fields for a specified character string

Syntax

CONTAINS(<expC>,[<expL>|<expN>])

See Also

BETWEEN(), CHROVERLAP(), EMPTY(), EVALUATE(), EXPRCHECK(), FOR(), HTML_TOPLAINTEXT(), INDEX, INLIST(), INRANGE(), ISALPHA(), ISBLANK(), ISDIGIT(), LOWER(), MAX(), MAXVALUES(), MIN(), MINVALUES(), MTOS(), PROPER(), SEEK, SEEK(), TYPE(), UPPER(), VARTYPE()

Description

The CONTAINS() function returns .T. (True) if the current record contains the specified character string, <expC>.

A case-insensitive search is performed on the current record's character fields. If the optional <expL> is .T. (True) or the optional <expN> is 1, memo fields are also checked, otherwise they are excluded from the search.

Parameters Description
<expC> The character string to search for. Delimit words or phrases with commas
<expL> If .T. (True), memos are included in the search.
<expN> If 1, memos are included in the search.

The CONTAINS() function is particularly useful in creating full text-search indexes, as shown in the example below.

Example

open database southwind
use products
// Restrict index to product records in category 2 (condiments) with a character field containing string "bottled", memos excluded
index on lower(productname) for contains("bottles,jars,cans",.F.) and categoryid = 2 tag bottled