0% found this document useful (0 votes)
1 views3 pages

Arithmetic & Comparison Operator in SQL

This pdf contains notes for SQL arithmetic operations

Uploaded by

anubhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

Arithmetic & Comparison Operator in SQL

This pdf contains notes for SQL arithmetic operations

Uploaded by

anubhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
- WHAT ARE SQL OPERATORS AND HOW DO THEY WORK? While handling data in databases, we often tend to perform different kinds of ‘operations to manipulate and retrieve data, SQL being the base of database management systems, offers various operators to perform such operations: What are SQL operators? SQL operators are reserved keywords used in the WHERE clause ‘of a SQL statement to perform arithmetic, logical and comparison operations. Operators act as conjunctions in SQL statements to fulfill multiple conditions in a statement, Since, there are different types of operators in SQL, let us unders section of this article on SQL operators. and the same in the next ‘Types of SQL Operators PI ARI HMMporators are used to perform operations such as addition multiplication, subtraction etc. Operator | Operation Description + ‘Addition “Add values on either side of the operator z Subtraction | Ust#tosubiract theright hand side value from the lefthand side value * ialiplication | Multiples the values present on each side ofthe operator Z Division Divides the left hand side value by the right hand side value Divides the lefthand side value by the right hand side value; a Moa and returns the remainder ae Example: Output: SELECT 40 +20; | 60 SELECT 40 - 20; 20 SELECT 40 * 20; 800 SELECT 40 / 20; 2 SELECT 40% 20;_| 0 OMPARI ‘These operators are used to perform operations such as ‘equal to, greater than, less than etc. ‘Operator | __ Operation Description e a Used to check ifthe values of both operands are equal or not.If they are equal, then it returns TRUE. : aa ie TRUE ifthe value of left operand is greater than the . Fae Checks whether the value oflet operand is Tess than the right operand, if yes returns TRUE. . Greater than or [Used to check f the left operand is greater than oF equal to = equal to the right operand, and returns TRUE, ifthe condition is tue. = ss than or equal_| Returns TRUE if the left operand is less than or equal to the = to right operand. ‘Used to check if values of operands are equal or not. If th Not equal to are not equal then, it returns TRUE. : = Thecks whether the left operand is not greater than the ei Not greater than | right operand, ifyes then returns TRUE; 1 Returns TRUE, if the left operand is not less than the right I< Not less than operand © scanned with OKEN Scanner 1 “Atul Mishra 23 2 Priya Kapoor’ 21 3 Rohan Singhania 24 4 ‘Akanksha Jain 20 5 Vaibhav Gupta 2 Example[Use equal to]: SELECT * FROM Students \ WHERE Age = 20; \ Output: aera [LastName Tagen 4 ‘Akanksha Jain 20 Example[Use greater than]: SELECT * FROM students WHERE Age > 23; Output: 5 Vaibhav Example[Use less than or equal to]: SELECT * FROM students WHERE Age <= 21; Output: LastName [Agel 2 Priya Kapoor 21 3 Rohan Singhania 21 4 ‘Akanksha Jain 20 Example [Not equal to): SELECT * FROM students WHERE Age > 25; 1 ‘Atul Mishra 23 2 Priya Kapoor 21 a Rohan Singhania 24 4 ‘Akanksha Jain 20 © scanned with OKEN Scanner LOGICAL OPERATORS The logical etc. operators are used to perform operations such as ALL, ANY, NOT, BETWEEN | Operator Coe Description —_ ALL Used to compare a specific value to all other values in a set ANY Compares a specific value to any of the values present in a set. UN Used to compare a specific value to the literal values mentioned. _ZBETWEEN Searches for values within the range mentioned. LAND | Allows the user to mention multiple conditions in a WHERE clause. rOR Combines multiple conditions in a WHERE clause. LOT A negate operators, used to reverse the output of the logical operator. EXISTS Used to search for the row’s presence in the table. TIKE Compares a pattern using wildcard operators. SOME Similar to the ANY operator, and is used compares a specific value to some of the values present in a set, © scanned with OKEN Scanner

You might also like