×

SQL Operators

Arithmetic Operators

Arithmetic operators are +, -, *, /, % performs addition, subtraction, multiplication, division, modulo respectively. Example:  
  • Select 100+222;
  • Select salary+100
From teacher Where teacher_id=1; Following output screen shows different arithmetic operations. We can perform single operation at a time or multiple operations.

Comparison Operators

Comparison operators ‘<’,   ‘<=’, ‘>’, >, =’, =’ performs less than, less than equal, greater than, greater than equal, equal respectively. Following output screen shows different comparison operators. Following output screen shows different queries with different comparison operations.  

Logical Operators

AND, OR, NOT, LIKE, IN, BETWEEN, ALL, SOME, ANY, EXISTS are logical operators from which some operators ALL, ANY, EXISTS, SOME used in sub queries. AND: It returns TRUE, if all the conditions separated by AND are TRUE. Example: Select * from teacher where salary>10000 and dept_name=’CS’; OR: It returns TRUE, if any of the conditions separated by OR is TRUE. Example: Select * from teacher where salary < 10000 OR dept_name=’IT’;   BETWEEN: It returns true, if the operands are within the range of comparison. Example: Select * from teacher where teacher_id between 4 and 8;   IN: It returns true if the operand is equal to one of the list of expressions. Example: Select * from teacher where teacher_id in (4,8); LIKE: It returns true if the operand matches a pattern. ‘_’ underscore represents single character. ‘%’ percent represents one or more characters. Example: Q1. Find out teachers whose name start with ‘a’? Select teacher_name from teacher where teacher_name like 'a%'; Q2 Find out teachers whose name end with ‘r’? Select teacher_name from teacher where teacher_name like '%r'; Q3 Find out teachers whose name contains letter ‘h’? Select teacher_name from teacher where teacher_name like '%h%'; Q4 Find out teacher whose name contains ‘h’ letter at third position? Select teacher_name from teacher where teacher_name like '__h%';   If the condition is not true. Example: Select teacher_name from teacher where teacher_name NOT like '%h%';   Reference: https://www.javatpoint.com/sql-operators

Related Topics

SQL FULL JOIN

In this section, we will help you understand the concept of the SQL FULL Join clause with a few examples. The SQL FULL Join query is executed to display the integrated...

3 minutes read.

SQL SELECT AND Operator

This SQL tutorial explains and helps us understand how to use the AND Operator in the SELECT query with examples. The AND Operator is used to fetch the table’s records if...

2 minutes read.

How to drop a column in SQL?

How to drop a column in SQL Introduction To delete a column from an already created table, one needs to use the ALTER command along with the DROP COLUMN clause. Syntax: ALTER TABLE tablename...

4 minutes read.

SQL Aggregate Operators

In SQL, the aggregate operators perform a calculation on multiple rows or multiple values of a single column and give the output a single value. Here, multiple rows of data are...

4 minutes read.

SQL FOREIGN KEY

In this article, we will learn about the FOREIGN KEY constraints and how to define a FOREIGN KEY constraint to build the relationship between two tables. In a Relational Databases Management...

4 minutes read.

How to compare date in SQL

In this section, we will learn about how dates can be compared in SQL. We can compare any random date with another date stored in a column of a table.This comparison...

4 minutes read.

SQL SELECT Database

In this tutorial, we will help you to understand and learn how to select the database in SQL with the help of examples. The database user or the administrator wants to...

3 minutes read.

SQL Data Definition Language

Data definition language directly effects on the structure/schema of the database. CREATE, ALTER, DROP are the commands of DDL.CREATE: Creates new database, table, or view of table.ALTER: Modifies the database or...

3 minutes read.

SQL SELECT MIN

The SQL Min() function is an aggregate function in SQL. SQL Min() returns the minimum value of a given condition. The expression may be numerical, or it may be an expression. The syntax...

5 minutes read.

SQL Comparision Operator

The Comparison Operator compares different data of the Structured Query Language table and checks whether the data are the same, less than, greater than, less than, or greater than equal....

14 minutes read.

SQL Count

Structured Query Language Count() Function is used with Structured Query Language SELECT Statement. SQL Count() function returns the number of items that match the specified criteria in the SELECT statement. Count()...

2 minutes read.

SQL DROP Database

This tutorial will help us understand how to drop a database from the SQL Server with a few examples. The DROP command removes all the objects stored in the database and...

4 minutes read.

DELETE VS DROP in SQL

This page contains all the information about the Delete command and Drop command concept and the difference between the DELETE and DROP commands in SQL. What is the DELETE command in...

3 minutes read.

SQL Aliases

SQL Aliases: These are used to give a temporary name for a column or table. These are used to make tables or columns more readable. These are used to rename the table...

2 minutes read.

SQL Aggregate Functions

In this tutorial, we will learn and understand the SQL Aggregate Functions concept with the help of examples. SQL Aggregate Function is a function used to perform calculation operations on one...

4 minutes read.

SQL Scalar Functions

TEACHER Table LCASE() Function The LCASE() function is used to return lower case values of specified column. Syntax: Select Lcase(column_name) from table_name; Example: Select Lcase(teacher_name) from teacher; Syntax: Select Lcase(column_name) from table_name [where condition]; Example: Select Lcase(teacher_name) from teacher where teacher_id=1; UCASE() Function The UCASE()...

1 minute read.

SQL CROSS Join

In this tutorial, we will help you understand the concept of the SQL CROSS Join clause with the few examples. The SQL CROSS Join query is used to join one or...

5 minutes read.

How to use GROUP BY clause in SQL

In this SQL article, we will learn about the GROUP BY clause and how to use it in SQL. We will also discuss using the GROUP BY clause with the...

6 minutes read.

Types of SQL JOIN

The SQL JOIN combines one or more than one tables based on their relationship. The SQL JOIN involves a parent table and a child table relationship. There are different types of...

10 minutes read.

SQL TABLE

SQL TABLE Structured Query Language (SQL) is a relational database (RDBMS) where data is stored in the form of tables, that is, in rows and columns. These tables are known as...

3 minutes read.