Skip to main content

Operators In SQL

Operators In SQL


Operators: SQL generally contains some reserved words that are used to perform operations such as Arithmetical, Comparison and Logical Operations etc. These reserved words are known as Operators.

Generally, there are three types of operators in SQL:

i.      SQL Arithmetic Operators

ii.     SQL Comparison Operators

iii.    SQL Logical Operators

SQL Arithmetic Operators

Let assume variable A holds 20 and variable B holds 60 then:

Operators                             

Description 

  

Example

 

+

Add

 

A+B= will give 80

 

-

Subtract

 

A-B= will give -40

 

*

Multiply

 

A*B= will give 1200

 

/

Division

 

B/A= will give 3

 

%

Modulo

 

B%A= will give 0

SQL Comparison Operator

Let assume variable A holds 20 and variable B holds 60 then:

Operators

Description


Example

=

Examines both operands value that are equal or not, if yes condition becomes true.

 

A=B is not true

!=

This is used to check the value of both operands are equal or not, if not condition become true.

 

A!=B is true

<> 

Examines the operands value equal or not, if not condition become true.

 

A<>B is true

> 

Examines the left operand value is greater than right operand, if yes condition becomes true.

 

A>B is not true

< 

Examines the left operand value is less than right operand, if yes condition becomes true

 

A<B is true

>=

Examines that the value of left operand is greater than or equal to the value of right operand or not, if yes condition become true.

 

A>=B is not true

<=

Examines that the value of left operand is less than equal to the value of right operand or not, if yes condition become true.

 

A<=B is true

SQL Logical Operators

Operators

 

Description

 

  AND

 

Return true if both expressions are true.

 

  OR

 

Return true if either expression is true.

 

  NOT

   Reverse the result of any other Boolean operator.

 

  LIKE

 

Return true if the operand matches a pattern.

 

BETWEEN

   Return true if the operand is within a range.

 

Comments

Popular posts from this blog

Conditional Statements In Java

  Conditionals Statement   A conditional statement  is a set of rules performed if a certain condition is met. A conditional statement begins with the keyword if followed by parentheses. The result of the evaluation is true or false. ·       ‘ if ‘ statement ·       ‘ if-else ‘ statement ·         Nested ‘ if ‘ statement ·       ‘ if-else - if ‘ statement IF statement: ‘IF’ statement is the most basic and simple statement among all the statements. For example- if a value is less than 0, return “Negative value”. Let’s see an example- IF-ELSE statement: The if-else is statement is an extended version of If. Let’s see an example- Nested IF-ELSE statement : In Java, when there is an if statement inside another if statement then it is known as nested if-else. Let’s see an example- IF-ELSE-IF: ‘ if-else-if ’ statement is used when we need to check mul...

Introduction to Java

Introduction to Java O verview of Java: 1.  Java is a high-level, robust, object-oriented, and secure programming language. 2.  Java was developed by James Gosling at Sun MicroSystem_Inc in 1991. 3.  Sun Microsystems released the first public implementation as Java 1.0 in 1996. 4.  James Gosling is known as the father of java. The language was initially called Oak. Since Oak was already a registered company, so James Gosling and his team changed the name from Oak to Java.   J ava Terminology 1. JDK: JDK stands for Java Development Kit. JDK is a set of tools it includes a compiler, Java Runtime Environment (JRE), Java debugger, Java doc, etc. 2. JRE : JRE stands for Java Runtime Environment. Java runtime environment helps in executing Java Programs. JRE includes a browser, JVM, applet supports, and plugins.   J ava Editions We have mainly three editions of java. 1.  Java Standard Editions (SE) 2.  Java Enterprises Edition (EE) 3.  Java Micro E...

Methods of String in java

  String in Java String:   A Java string is  a sequence of characters that exist as an object of the class java. lang. Here is  the list of important methods available in the java string class: Ø  startsWith ( ): It checks if the string starts with the given prefix. If yes then return true else false. Ø  endsWith () : It checks if the string ends with the given suffix. If yes then return true else false. Ø  substring(int begin index) : It return s  the substring of the string. The substring start s  with the character at the specified index. Ø   substring(Int begin index , int end index) : Returns the substring. The substring starts with the character at begin index and ends with the character at end index. Ø  toLowerCase() : It converts all  the character s  of the string into lower case(Small Letters).   Ø  toUpperCase() : It converts all the character s  of the string into upper case(Capital Let...