Please note that the information on
this page is related to an older version of Microsoft SQL
Server.
Click on SQL Server
Tutorials for new training content and material. In
addition we have FREE SQL
Tutorial videos here, so feel free to download
the demos. Our partners also manage two blogs on
the following SQL Server Versions:
-SQL Server 2008
Blog -SQL
Azure Blog
Please send any comments or suggestion
to info@sqlserver2008tutorial.com
Operators are used to limit the number of
results from the query. Also they are used for mathematical and
logical operations. Here are a few types of operators.
Standard Operators:
=
equal to <>, !=
not equal to
< less than <=
less than or equal to
> greater than >=
greater than or equal to
between used to show between two numbers
Logical Operators:
AND used when both conditions are included
OR used when either of the condition is true
NOT opposite of the logical value
Null Operator:
IS NULL this checks if the field has a null
IS NOT NULL this checks to see if it is not null
List Operator:
IN included in the list e.g.
IN ('Phoenix', 'Dallas', 'San Diego') checks to make sure the city is one of the three listed
NOT IN not included in the list
BETWEEN used to limit the values in a range e.g.
BETWEEN 55 AND 65 checks to see that the age of the employee is in the correct range
Character Operator:
LIKE equal to some character (use quotes)
NOT LIKE not equal to the character
Note: With the LIKE operator, you can also use % around the character to return similar patterns e.g.
If the list of Names include John, Mike, Tim and Josh
LIKE 'Jo%' with return John and Josh
|