23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Relational operators<br />

210<br />

• The string_constant may be a string constant or a scalar function call.<br />

• The escape_character must be a one character string constant.<br />

• A percent sign ( % ) in the pattern matches zero or more characters of the column string.<br />

• An underscore symbol ( _ ) in the pattern matches any single character of the column<br />

string.<br />

• The LIKE predicate is multi-byte enabled. The string_constant and the<br />

escape_character may contain multi-byte characters, and the escape_character can be<br />

a multi-byte character. A percent sign ( % ) or an underscore ( _ ) in the string_constant<br />

can represent a multi-byte character. However, the percent sign or underscore itself must<br />

be the single-byte ASCII encoding.<br />

Example This example illustrates three ways to use the LIKE predicate:<br />

cust_name LIKE ’%Computer%’<br />

cust_name LIKE ’___’<br />

item_name LIKE ’%\_%’ ESCAPE ’\’<br />

In the first LIKE clause, for all strings with the substring ’Computer’ the predicate evaluates to<br />

true. In the second LIKE clause, for all strings which are exactly three characters long the<br />

predicate evaluates to true. In the third LIKE clause the backslash character ( \ ) is specified as<br />

the escape character, which means that the special interpretation given to the underscore<br />

character ( _ ) is disabled. The pattern evaluates to TRUE if the item_name column has embedded<br />

underscore characters.<br />

EXISTS Predicate<br />

The EXISTS predicate can be used to check for the existence of specific rows. The<br />

query_expression returns rows rather than values. The predicate evaluates to true if the number<br />

of rows returned by the query_expression is nonzero. This is the syntax for an EXISTS predicate:<br />

Syntax<br />

EXISTS (query_expression)<br />

Example In this example, the predicate evaluates to true if the specified customer has any orders:<br />

EXISTS (SELECT * FROM order_tbl<br />

WHERE order_tbl.custid = ’888’ ;)<br />

IN Predicate<br />

The IN predicate can be used to compare a value with a set of values. If an IN predicate specifies<br />

a query expression, then the result table it returns can contain only a single column. This is the<br />

syntax for an IN predicate:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!