Comparison operators in SQL Server
This article will show the comparison operators that are used to check for equilibrium along with more advanced operators in SQL Server. Readers can refer to the article Operator in SQL.
The comparison operator is used in the WHERE clause to determine which record selection. This is a list of comparison operators you can use in SQL Server (T-SQL).
Operator Description = Equal to <> Not equal to! = Not equal to> Greater than> = Greater than or equal to Not greater!There are many comparison operators in SQL Server and Transact-SQL. Here's how to use some common operators.
Example - Peer operator
SELECT *
FROM nhanvien
WHERE ten = 'Jane';
In this example, the SELECT statement returns results from rows from the table with employees named Jane.
Example - Non-peer operator
In SQL Server, you can use <> or! = To check non-peer properties in queries.
SELECT *
FROM nhanvien
WHERE ten <> 'Jane';
The SELECT statement above will return rows in the nhanvien table whose name is not Jane. The above command can be written differently as follows. Both queries produce the same result set.
SELECT *
FROM nhanvien
WHERE ten != 'Jane';
Example - Larger operator
SELECT *
FROM nhanvien
WHERE nhanvien_id > 3000;
The result of the above SELECT statement is the rows in the table where the employee ID is greater than 3000, the employee ID of 3000 will not be in the result.
Example - Operator greater than or equal to
SELECT *
FROM nhanvien
WHERE nhanvien_id >= 3000;
The above example will return rows with employee ID greater than or equal to 3000 in the table.
Example - Smaller operator
SELECT*
FROM nhanvien
WHERE nhanv
ien_id <500;
Similarly, the result of this command is the rows in the bank with the employee ID less than 500, not including the ID 500.
For example - Operator less than or equal to
SELECT *
FROM nhanvien
WHERE nhanvien_id
<= 500;
The result of this command is the rows in the table with the value of less than or equal to 500.
Example - Advanced operator or logical operator
The advanced operators below will have specific instructions for them.
IN ()
NOT
BETWEEN
IS NULL
IS NOT NULL
LIKE
EXISTS
Previous article: FROM clause in SQL Server
Next article: WHERE clause in SQL Server
You should read it
May be interested
- Operator in JavaScriptwe see the following simple expression: 4 + 5 is equal to 9. here 4 and 5 are operands and '+' called operator - operator.
- UNION ALL operator in SQL Serverthe union all operator is used to combine the result set from 2 or more select statements in sql server.
- Comparison functions in Excel - How to use comparison functions and examples using comparison functionscomparison functions in excel - how to use comparison functions and examples using comparison functions with a large amount of data, you want to check for duplicates by checking normally, it is really hard. in this article, introduce to you the functions
- OR conditions in SQL Serverthe or condition in sql server (transact-sql) is used to check multiple conditions.
- 5 best file comparison tool for Macthe file comparison tool helps you compare and merge the differences between two (or more) versions of the same file. today's article will look at some of the best file comparison apps for macos.
- INTERSECT operator in SQL Serverin sql server (transact-sql), intersect operator is used to return records in both data sets or select statements.
- Load the stack of assignment operators in C ++you can overload the assignment operator (=) as you can with other operators in c ++ and it can be used to create an object like copying constructors.
- The difference between desktop and serveris the desktop and server the same? if the computer is different from the server, what is the difference? how to distinguish desktop and server? tipsmake.com has summarized some of the main ideas for you to know the desktop and server.
- How to compare texts onlinethe document comparison tool helps us know the content changes between two text files.
- 5 websites compare the speed and CPU performance from the most accurate Benchmark pointalways, to find out what is the most optimal, we have to apply comparisons, so what does the cpu compare to?