Subject Re: [firebird-support] Question about "IN"
Author Helen Borrie
At 05:00 PM 4/01/2004 -0500, you wrote:
>Nando Dessena wrote:
> > Lee,
> >
> > L> SELECT Field1, Field2 FROM MyTable WHERE 'ConstantValue' IN Field1;
> >
> > what does Field1 contain? A single value? A list of values? An array?
> > Please give example data and result you wish to get.
> >
> > Ciao
>
>Thanks Nando,
>
>More than likely, VarChar(250);

Lee,
Tell us what you want to achieve...

The IN() predicate takes a comma-separates list of constants as an
argument. The expression tests whether the column named on the left side
matches any one of the values in the list, e.g.

SELECT Field1, Field2 FROM MyTable
WHERE aField IN(constvalue1, constvalue2, ....);

A variant is to get the comparison list via a scalar subquery:

SELECT Field1, Field2 FROM MyTable
WHERE aField IN(select xField from anotherTable where....);

If you want to determine whether a constant string is found inside a
character column, use CONTAINING:

SELECT Field1, Field2 FROM MyTable
WHERE Field1 CONTAINING 'ConstantValue' ;

Related predicates are LIKE (which can take wildcards) and STARTING WITH.

/heLen