Difference between revisions of "Relational and Logical Operators"

From Catglobe Wiki
Jump to: navigation, search
(Undo revision 23319 by Cg pham (talk))
Line 1: Line 1:
<p><span class="fck_mw_template">{{HelpFiles}}</span>  
+
<img _fck_mw_template="true" _fckrealelement="0" _fckfakelement="true" src="http://wiki.catglobe.com/extensions/FCKeditor/fckeditor/editor/images/spacer.gif" class="FCK__MWTemplate">  
</p>
+
 
<h3> Relational and Logical Operators  </h3>
+
=== Relational and Logical Operators  ===
<p>Relational refers to the relationships that values can have with one another, and logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, they are often used in combination with the logical operators.  
+
 
</p><p>The relational operators are as follows:  
+
Relational refers to the relationships that values can have with one another, and logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, they are often used in combination with the logical operators.  
</p><p>Not equal to  
+
 
</p>
+
The relational operators are as follows:  
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
+
 
 +
Not equal to
 +
 
 +
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 +
|- align="left" valign="top"
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''Operator'''
 +
 
 +
| width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''Meaning'''
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" |
 +
==
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Equal to
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" | &nbsp;!=<br>  
 +
| width="594" style="border:1px solid #010101;" |
 +
Not equal to  
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" |
 +
&gt;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Greater than
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" |
 +
&lt;
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Less than
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" |
 +
&gt;=
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Greater than or equal to
 +
 
 +
|- align="left" valign="top"
 +
| width="594" style="border:1px solid #010101;" |
 +
&lt;=
 +
 
 +
| width="594" style="border:1px solid #010101;" |
 +
Less than or equal to
 +
 
 +
|}
 +
 
 +
Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other.
 +
 
 +
&lt;tbody&gt; &lt;/tbody&gt;
 +
 
 +
{| width="1189" cellspacing="0" cellpadding="2" border="1" class="tableintopic" style="border-collapse:collapse; border:1px solid #010101"
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''array'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''bool'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''number'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''question'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''range'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''string'''
 +
 
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''datetime'''
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''array'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''bool'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''number'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''question'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''range'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''string'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
|- align="left" valign="top"
 +
| width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;" |
 +
'''datetime'''
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
&nbsp;
 +
 
 +
| width="149" style="border:1px solid #010101;" |
 +
==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=
 +
 
 +
|}
 +
 
 +
The outcome of the relational and logical operators is a value of type bool.
  
<tr align="left" valign="top">
 
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;">
 
<p><b>Operator</b>
 
</p>
 
</td><td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;">
 
<p><b>Meaning</b>
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>==
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Equal to
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;"> &nbsp;!=<br />
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Not equal to
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&gt;
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Greater than
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&lt;
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Less than
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&gt;=
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Greater than or equal to
 
</p>
 
</td></tr>
 
<tr align="left" valign="top">
 
<td width="594" style="border:1px solid #010101;">
 
<p>&lt;=
 
</p>
 
</td><td width="594" style="border:1px solid #010101;">
 
<p>Less than or equal to
 
</p>
 
</td></tr></table>
 
<p>Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other.
 
</p>
 
 
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
 
<table width="1189" cellspacing="0" cellpadding="2" border="1" style="border-collapse:collapse; border:1px solid #010101" class="tableintopic">
&lt;tbody&gt;<tr align="left" valign="top">
+
<tbody><tr align="left" valign="top">
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
+
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">Operator</strong></p>
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">question</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">range</strong></p>
 
</td>
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">string</strong></p>
 
 
</td>
 
</td>
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">datetime</strong></p>
+
<td width="594" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">Meaning</strong></p>
 
</td>
 
</td>
 
</tr>
 
</tr>
 
<tr align="left" valign="top">
 
<tr align="left" valign="top">
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">array</strong></p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">&amp;&amp;</p>
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
 
</td>
 
</td>
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical and</p>
 
</td>
 
</td>
 
</tr>
 
</tr>
 
<tr align="left" valign="top">
 
<tr align="left" valign="top">
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">bool</strong></p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">||</p>
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
 
</td>
 
</td>
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical or</p>
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
 
</td>
 
</td>
 
</tr>
 
</tr>
 
<tr align="left" valign="top">
 
<tr align="left" valign="top">
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">number</strong></p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">!</p>
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
 
</td>
 
</td>
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
+
<td width="594" style="border:1px solid #010101;"><p class="bodytext">Logical negation</p>
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">question</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">range</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">string</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
</tr>
 
<tr align="left" valign="top">
 
<td width="149" bgcolor="#C0C0C0" style="border:1px solid #010101;"><p class="bodytext"><strong class="specialbold">datetime</strong></p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">&nbsp;</p>
 
</td>
 
<td width="149" style="border:1px solid #010101;"><p class="bodytext">==,&nbsp;!=, &gt;, &lt;, &lt;=, &gt;=</p>
 
 
</td>
 
</td>
 
</tr>
 
</tr>
  
&lt;/tbody&gt;</table>
+
</tbody></table>
<p>The outcome of the relational and logical operators is a value of type bool.
+
 
</p><a _fcknotitle="true" href="Category:Operators">Operators</a>
+
&lt;a _fcknotitle="true" href="Category:Operators"&gt;Operators&lt;/a&gt;

Revision as of 08:34, 5 January 2012

<img _fck_mw_template="true" _fckrealelement="0" _fckfakelement="true" src="spacer.gif" class="FCK__MWTemplate">

Relational and Logical Operators

Relational refers to the relationships that values can have with one another, and logical refers to the ways in which true and false values can be connected together. Since the relational operators produce true or false results, they are often used in combination with the logical operators.

The relational operators are as follows:

Not equal to

Operator

Meaning

==

Equal to

 !=

Not equal to

>

Greater than

<

Less than

>=

Greater than or equal to

<=

Less than or equal to

Those relational operators cannot be applied to all data types and in some cases, two values of different types cannot be compared to each other.

<tbody> </tbody>

 

array

bool

number

question

range

string

datetime

array

 

 

 

 

=, !

 

 

bool

 

=, !

=, !

 

 

=, !

 

number

 

=, !

=, !=, >, <, <=, >

 

=, !

 

 

question

 

 

 

 

 

 

 

range

=, !

 

=, !

 

 

 

 

string

 

=, !

=, !

 

 

=, !

 

datetime

 

 

 

 

 

 

=, !=, >, <, <=, >

The outcome of the relational and logical operators is a value of type bool.

<tbody> </tbody>

Operator

Meaning

&&

Logical and

||

Logical or

!

Logical negation

<a _fcknotitle="true" href="Category:Operators">Operators</a>