SQL Operators are a means of performing mathematical operations on different types of data in order to achieve a desired result. Operators are often used to manipulate more complex data structures.
For example, compared to other languages, the SQL relational language offers a limited number of operators. To help with that challenge, we have created this article to demonstrate the most commonly used operators in SQL.
SQL Operators – Filter
WHERE Clause :
- Used to specify a Condition while fetching the data from a single table or by joining with multiple tables.
- Not only used in the SELECT statement, but it is also used in the UPDATE, DELETE statement, etc,
Example:
select * from [Table] where [emp_id=3];
SQL Operators – Logical
Operator | Illustrative Example | Result |
---|---|---|
AND | (5<2) AND (5>3) | FALSE |
OR | (5<2) OR (5>2) | TRUE |
NOT | NOT(5<2) | TRUE |
Sample Queries:
select * from [table_name] where first_name=’jhon’ and age=30;
select * from [table_name] where first_name=’jhon’ or age=20;
select * from [table_name] where first_name=’jhon’ not age!=20;
SQL Operators – comparison
Symbol | Meaning |
---|---|
Equal to | |
> | Greater then |
>= | Greater thn or equal to |
< | Less than |
<= | Less than or equal to |
<> or != | Not equal to |
Sample Queries:
select * from [table_name] where first_name=’rocky’ and age <=30;
select * from [table_name] where first_name=’rocky’ and age >=30;
SQL Operators – Special
Special Operators | |
---|---|
BETWEEN | Checks an attribute value within range |
LIKE | Checks an attribute value matches a given string pattern |
IS NULL | Checks an attribute value is NULL |
IN | Checks an attribute value matches any value within a value list |
DISTINCT | Limits values to unique values |
Sample Queries:
SELECT * FROM [Table name] WHERE [column name] between 25 and 35;
SELECT * FROM [Table name] WHERE [column name] like ‘rock’;
SELECT * FROM [Table name] WHERE [column name] is null;
SELECT * FROM [Table name] WHERE [column name] in (20, 30, 35);
SELECT DISTINCT ‘[Column name]’ from employees;
SQL Operators – Aggregations
Aggregations Functions | |
---|---|
Avg() | Returns the average value from specified columns |
Count() | Returns Number of table rows |
Max() | Returns largest value among the records |
Min() | Returns smallest value among the records |
Sum() | Returns the sum of specified column values |
Sample Queries:
select avg([column]) from [table_name];
select count(*) from [table_name];
select min([column]) from [table_name];
select max([column]) from [table_name];
select sum([column]) from [table_name];
1. How to Convert SQL Server.
You can easily convert your SQL Database to the different platforms just flow a few steps.
Before convert SQL server we will require 3 software in your systems:
1. MSSQL Server Or Microsoft SQL Management Studio
2. XAMPP Server
3. Data Loader
4. Click here…
2. SQL Server queries, Create a Table, Database
- What’s SQL Server ?
- What’s SQL server Database ?
- Types of SQL Server Data Models:
- SQL Constraints
- DDL – Data Definition Language.
- DML – Date Manipulation Language
- DCL – Data Control Language
- TCL – Transaction Control
- SQL Server Queries Example..
- Click here…
Enjoyed looking through this, very good stuff, regards. “A man may learn wisdom even from a foe.” by Aristophanes.