Comparison Expression

In OQL, operators like ==, !=, >=, <= can be used to make up of a Comparison Expression. Boolean Expression is applied in where, on, having and case clause etc. For example:

SelectQuery qryProduct = OQL

  .SelectFrom(NW.Product)

  .Where(NW.Product.UnitPrice >= 50

    && (NW.Product.UnitsInStock <= 20 || NW.Product.UnitsOnOrder > 0));

The SQL statements generated as follows (taking SQL Server as an example)

SELECT [Products].*

FROM [Products]

WHERE

  [Products].[UnitPrice] >= 50 AND

  (

    [Products].[UnitsInStock] <= 20 OR

    [Products].[UnitsOnOrder] > 0

  )

When a Comparison Expression is used as an Object Expression, it can occur in a Select clause.

Related Topics

Boolean Expression