<@INTERSECT ARRAY1=arrayVarName1 ARRAY2=arrayVarName2 [COLS=compCol [compType] [, ...]] [SCOPE1=scope1] [SCOPE2=scope2] [{array attributes}]>
Returns the intersection of two arrays, that is, an array containing only those rows that exist in both input arrays.
The two input arrays are not modified. To store the result of this meta tag in a variable, use a variable assignment.
The ARRAY1 and ARRAY2 attributes specify the names of variables containing arrays. The optional COLS attribute specifies the column(s) to consider when determining whether two rows are the same: the columns are specified using column numbers or names (compCol), with an optional comparison type (compType). The arrays must have the same number of columns; otherwise, an error is generated.
Valid comparison types are SMART (the default), DICT, ALPHA and NUM. DICT compares columns alphabetically, irrespective of case. ALPHA performs a case-sensitive comparison. NUM compares columns numerically. SMART checks whether values are numeric or alphabetic and performs a NUM or DICT comparison.
If no COLS attribute is specified, the intersection of the two arrays is accomplished via a SMART comparison type that examines all columns.
The SCOPE1 and SCOPE2 attributes specify the scope of the variables specified by ARRAY1 and ARRAY2, respectively. If the attribute is not specified, the default scoping rules are used.
There are array-returning attributes that can be used to specify prefixes and suffixes for the returned array, rows within the array, and columns within the rows. They are described in the section Array-to-Text Conversion Attributes. By default, the returned array is formatted as an HTML table.
Meta tags are permitted in any of the attributes.
The variable new contains the following array:
<@INTERSECT ARRAY1="p_items" ARRAY2="new"> returns:
and the variable test2 contains:
<@INTERSECT ARRAY1="test" ARRAY2="test2"> returns:
The variable usr2 contains the following array:
To find users that appear in both arrays, you would find the intersection of the two arrays based on the first two columns: <@INTERSECT ARRAY1="usr1" ARRAY2="usr2" COLS="1, 2"> returns:
$1123.75 1 |
| 1 Tango returns just one of the rows that have the same values in the specified columns (1 and 2). |
Only columns 1 and 2 are specified as relevant; the different values in the other columns are ignored for the purposes of comparison.
Var_B contains the following array:
<@IF EXPR="<@INTERSECT Var_A
Var_B>">
Var_B is in Var_A
<@ELSE>
Not in Var_A
</@IF>
For more information, see Array evaluation.
This is because an array value specified as an expression (in <@CALC> or <@IF>) returns the number of rows in that array.
Array-to-Text
Conversion Attributes
<@DISTINCT>
<@FILTER>
<@SORT>
<@UNION>
Copyright © 1999, Pervasive Software. All rights reserved.