Difference between revisions of "SQL Logical operators"
From Recital Documentation Wiki
Yvonnemilne (Talk | contribs) |
Yvonnemilne (Talk | contribs) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Purpose== | ==Purpose== | ||
Logical Operators | Logical Operators | ||
Line 42: | Line 35: | ||
<code lang="recital"> | <code lang="recital"> | ||
// AND | // AND | ||
− | + | 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 > 10000; |
− | WHERE paid_date < date() AND ord_value > 10000 | + | ORDER BY name, paid_date |
− | ORDER BY name, paid_date | + | |
// NOT | // NOT | ||
− | + | SELECT name, address, balance, cost*1.15; | |
− | SELECT name, address, balance, cost*1.15 | + | FROM accounts; |
− | FROM accounts | + | WHERE paid_date < date() AND NOT ord_value BETWEEN 0 AND 10000; |
− | WHERE paid_date < date() AND NOT ord_value BETWEEN 0 AND 10000 | + | ORDER BY name, paid_date |
− | ORDER BY name, paid_date | + | |
// OR | // OR | ||
− | + | SELECT name, address, balance, cost*1.15; | |
− | SELECT name, address, balance, cost*1.15 | + | FROM accounts; |
− | FROM accounts | + | WHERE paid_date < date() OR ord_value > 10000; |
− | WHERE paid_date < date() OR ord_value > 10000 | + | ORDER BY name, paid_date |
− | ORDER BY name, paid_date | + | |
// XOR | // XOR | ||
− | + | SELECT name, address, balance, cost*1.15; | |
− | SELECT name, address, balance, cost*1.15 | + | FROM accounts; |
− | FROM accounts | + | WHERE paid_date < date() OR ord_value > 10000; |
− | WHERE paid_date < date() OR ord_value > 10000 | + | ORDER BY name, paid_date |
− | ORDER BY name, paid_date | + | |
</code> | </code> | ||
==Products== | ==Products== | ||
− | Recital | + | Recital, Recital Server |
[[Category:Documentation]] | [[Category:Documentation]] | ||
− | [[Category:SQL]] | + | [[Category:SQL|Operators,Logical]] |
Latest revision as of 15:48, 5 July 2011
Purpose
Logical Operators
Syntax
<condition1> AND <condition2> NOT <condition> <condition1> OR <condition2> <condition1> XOR <condition2>
See Also
INSERT, SQL OPERATORS, SELECT, UPDATE
Description
Operator | Description |
---|---|
AND | True if <condition1> and <condition2> conditions are both true, otherwise False |
NOT | True if the <condition> is false, otherwise False |
OR | True if <condition1> or <condition2> is true or if both conditions are true, otherwise False |
XOR | True if <condition1> or <condition2> is true but not both, otherwise False |
Example
// AND SELECT name, address, balance, cost*1.15; FROM accounts; WHERE paid_date < date() AND ord_value > 10000; ORDER BY name, paid_date // NOT SELECT name, address, balance, cost*1.15; FROM accounts; WHERE paid_date < date() AND NOT ord_value BETWEEN 0 AND 10000; ORDER BY name, paid_date // OR SELECT name, address, balance, cost*1.15; FROM accounts; WHERE paid_date < date() OR ord_value > 10000; ORDER BY name, paid_date // XOR SELECT name, address, balance, cost*1.15; FROM accounts; WHERE paid_date < date() OR ord_value > 10000; ORDER BY name, paid_date
Products
Recital, Recital Server