Export (0) Print
Expand All

WITH -- AS Group Alias Predicate

Column group aliases provide a way to use shorter names in place of the name of a column or a group of columns. The optional group alias predicate is part of the WHERE clause. Its syntax follows:

...WHERE[ WITH(<columns>) AS #<alias_name>]
[,WITH(<columns>) AS #<alias_name>]

You can specify more than one group alias, separating the WITH...AS predicates by commas.

When a group alias is referred to in a WHERE clause predicate, the condition is applied to each column in the group. The logical values resulting from matching each column are combined by using the logical OR operator.

An alias must be defined before it can be used, and it can be used only within the WHERE clause. The alias name must be a regular identifier preceded by a required pound sign (#).

The column specifier can contain one or more column specifiers, separated by commas. The list of columns must be enclosed in parentheses and weighting can be assigned to each. Each column has the following syntax:

<column_identifier> [<weight_assignment>]

For information on specifying column weights, see FREETEXT Predicate and CONTAINS Predicate.

The column identifier can be regular or delimited.


The following WHERE clause examples demonstrate when and how you can use the group alias predicate. The first example shows a more repetitive WHERE clause that does not use group aliasing.

    FREETEXT("System.ItemNameDisplay",'"computer software"')
    FREETEXT("System.Title",'"computer software"')
    FREETEXT("System.Keywords",'"computer software"')

The preceding example can be simplified by using a group alias, as shown in the following example.

    AS #Doc-Descriptions
    FREETEXT(#Doc-Descriptions,'"computer software"')

The following is an example of positive weighting where the Title property is given more weight in determining the relative rank.

    AS #Doc-Descriptions
    FREETEXT(#Doc-Descriptions,'"computer software"')

The following is an example of negative weighting where the Title property with weight of 0 is not considered.

    AS #Doc-Descriptions
    FREETEXT(#Doc-Descriptions,'"computer software"')

Related topics

FREETEXT Predicate
Full-Text Predicates
Non-Full-Text Predicates



Community Additions

© 2014 Microsoft