Difference between revisions of "IN Predicate"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Special predicate | Special predicate | ||
Line 16: | Line 9: | ||
==See Also== | ==See Also== | ||
− | [[ | + | [[SQL INSERT|INSERT]], [[SQL Predicates|PREDICATES]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]] |
Line 29: | Line 22: | ||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | + | SELECT name, address, balance, cost*1.15; | |
− | SELECT name, address, balance, cost*1.15 | + | FROM accounts; |
− | FROM accounts | + | WHERE paid_date < date() AND ord_value IN (100, 200, 300); |
− | WHERE paid_date < date() AND ord_value IN (100, 200, 300) | + | ORDER BY name, paid_date |
− | ORDER BY name, paid_date | + | |
− | + | SELECT name, address, balance, rep_id; | |
− | SELECT name, address, balance, rep_id | + | FROM accounts; |
− | FROM accounts | + | WHERE rep_id IN (SELECT emp_id from employees where location = 'MA'); |
− | WHERE rep_id IN (SELECT emp_id from employees where location = | + | ORDER BY name |
− | ORDER BY name | + | |
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital, Recital Server |
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
− |
Latest revision as of 17:18, 22 December 2009
Purpose
Special predicate
Syntax
<expression> [NOT] IN (<value list>) <expression> [NOT] IN (<nested select>)
See Also
INSERT, PREDICATES, SELECT, UPDATE
Description
IN is a special predicate to evaluate whether the specified <expression> is equal to one of the values in the <value list> or <nested select>. The <value list> contains a list of comma separated values. The <nested select> is an SQL SELECT clause.
The optional NOT evaluates whether the specified <expression> is not equal to any of the values in the <value list> or <nested select>.
The data type must be the same for the <expression> and all the values in <value list> or returned by the <nested select>.
Example
SELECT name, address, balance, cost*1.15; FROM accounts; WHERE paid_date < date() AND ord_value IN (100, 200, 300); ORDER BY name, paid_date SELECT name, address, balance, rep_id; FROM accounts; WHERE rep_id IN (SELECT emp_id from employees where location = 'MA'); ORDER BY name
Products
Recital, Recital Server