Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
13 views
SQL Operator
Uploaded by
MANAS TIWARI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SQL Operator For Later
Download
Save
Save SQL Operator For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
13 views
SQL Operator
Uploaded by
MANAS TIWARI
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save SQL Operator For Later
Carousel Previous
Carousel Next
Save
Save SQL Operator For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 10
Search
Fullscreen
SQL Operators Arithmetic operators Addition operator (+): Adds two or more numeric values. Eg. SELECTS +4; The result will be 9. O Subtraction Operator (-): The - symbol subtracts one number from another Eg. SELECT 10-1 The result will be -1 © Multiplication (*): The * symbol multiplies two numbers together. Eg. SELECT 10* 10; The result will be 100; C Division (/): Divides one numeric value by another. Eg. SELECT 10/2; The result will be 6. GO Remainder/Modulus (%): The % symbol (sometimes referred to as Modulus) returns the remainder of one number divided by another. Eg SELECT 10% 4; The result will be 2. C2 Bitwise AND (&): Performs a bit-by-bit comparison of two expressions and retums a result that has 1s in the positions where both input expressions have 1s and 0s in all other positions.Eg. SELECT 5 & 3; The result would be 1. C Bitwise OR (): Performs a bit-by-bit comparison of two expressions and retums a result that has 18 in the positions where either of the input expressions has 1 and Os in all other positions. Eg. SELECT 5 3; The result would be 7. C Bitwise XOR (4): Performs a bit-by-bit comparison of two expressions and returns a result that has 1s in the positions where either of the input expressions has 4s but not both, and 0s in all other positions. Eg. SELECT 543; The result would be 6. C Bitwise NOT (~): inverts all the bits of an expression, effectively changing all Os to 18 and all 1s to 0s. Eg. SELECT ~3; The result would be -4. C Left shift (<<): shits all the bts of an expression to the lot by a specified number of positions. Eg. SELECT 5 << 1; The result would be 10. © Right shift (>>): shifts all the bits of an expression to the right by a specified number of positions. Eg. SELECT 5 >> 1; The result would be 2.1D Name SALARY 1 John 45000 2 Jane 50000 3 Bob. 55000 4 Alice 60000 Table: Employees © Equal to (=): Retums true if two expressions are equal Eg, ‘SELECT Name FROM employees WHERE salary = 50000; This query would return Name from the employees table where the value in the salary column #s equal to 50000. ~ Output Jane O Not equal to (<> or !=) Retums true if two expressions are not equal. Eg ‘SELECT Name FROM employees WHERE salary != 50000; This query would return Name from the employees table where the value in the salary column és not equal to 50000. ~ Output John Bob Alice C Greater than (>): Retums true ifthe first expression is greater than the second expression. Eg ‘SELECT Name FROM employees WHERE salary > 50000; This quory would return Name from the employees table where the value in the salary column és greater than 50000, ~ Output Bob AliceCO Less than (<): Retums true ifthe fist expression is less than the second expression. Eg. SELECT Name FROM employees WHERE salary < 50000; This query would return Name from the employees table where the value in the salary column fs less than 0000, ~ Output John O Greater than or equal to (>=): Retums true ifthe first expression is greater than or equal to the second expression. Eg. ‘SELECT Name FROM employees WHERE salary >= 55000; This query would return Name from the employees table where the value in the salary column is greater than or equal to 50000. ~ Output Bob Alice C Less than or equal to (<=): Returns true ifthe first expression is less than or equal to the second expression. Eg ‘SELECT Namo FROM employees WHERE salary <= 50000; This quory would return Name from the employees table where the value in the salary column is less than or equal to 50000. ~ Output John Janefirst_name last_name age location John’ Doe 35 New york. Jane Smith 40 London Bob Johnson, 45 Paris Alice Brown 50 London Charlie Wilson 30 Tokyo Table: users O ALL The ALL operator returns TRUE if all of the subquery values meet the specified condition. In the below example, we are filtering all users who have an age that is greater than the highest age of users in London. ‘SELECT first_name, last_name, age, location FROM users WHERE age > ALL (SELECT age FROM users WHERE location = ‘London’); Output: first_name | last_name age location Bob Johnson 45 Paris Alice Brown 50 London O ANY/SOME The ANY operator returns TRUE if any of the subquery values meet the specified condition. In the below example, we are filtering all praducts which have any record in the orders table. The SOME operator achieves the same result. SELECT first_name FROM users WHERE age > ANY (SELECT age FROM users);Output: first_name John’ Jane Bob: Alice Charlie O AND ‘The AND operator returns TRUE if all of the conditions separated by AND are true. In the below example, we are filtering users that have an age of 20 and a location of, London, SELECT* first_name | last_name age location Alice Brown 50 London O BETWEEN ‘The BETWEEN operator filters your query to only return results that fit a specified range. SELECT* FROM users WHERE age BETWEEN 40 AND 50;Output: first_name last_name age location Jane Smith 40 London Bob Johnson 45 Paris Alice Brown 50 London O exists ‘The EXISTS operator is used to fitter data by looking for the presence of any record ina subquery. SELECT* FROM usors WHERE EXISTS (SELECT 1 FROM users WHERE location = ‘London’); Output: first_name last_name age location Jane ‘Smith 40 London Alice Brown 50 London OIN ‘The IN operator includes multiple values set into the WHERE clause. SELECT* FROM users WHERE first_name IN (‘Bob’, ‘Fred’, ‘Harry’); Output: first_name | last_name age location Bob Johnson 45 ParisO NOT ‘The NOT operator retums results if the condition or conditions are not true. SELECT* FROM users WHERE first_name NOT IN (‘Bob’, ‘Fred’, ‘Harry’); Output: first_name last_name age location John Doe 35 New york Jane ‘Smith 40 London Alice Brown 50 London Charlie Wilson 30 Tokyo OOR ‘The OR operator retums TRUE if any of the conditions separated by OR are true. In the below example, we are filtering users that have an age of 30 or a location of London. SELECT FROM users WHERE age = 30 OR location = ‘London’; Output: first_name last_name age location Jane Smith 40 London Alice Brown 50 London Chattie ‘Wilson 30 Tokyo OS NULL The IS NULL operator is used to filtering results with a value of NULL. SELECT * FROM users WHERE age IS NULL; OutputEmpty result, as no record has age column NULL; O LIKE The LIKE operator searches for a specified pattern in a column. (For more information on how!why the % is used here, see the section on the wildcard character operator). SELECT FROM users WHERE first_name LIKE ‘%4Bob%'; Output: first_name | last_name age Bob Johnson 45 NOT LIKE operator: The NOT LIKE operator is used to searching for a specified pattern in a string and return the opposite of the LIKE operator. SELECT* FROM users WHERE first_name NOT LIKE 'J%'; Output: first_name last_name age location John: Doe 35 New york Jane Smith 40 London C Concatenation operator (||): The concatenation operator is used to combine {wo or more strings into a single string. Example: SELECT first_name ||" ‘|| last_name AS full_name FROM users;Output:
You might also like
SQL Cheat Sheet
PDF
No ratings yet
SQL Cheat Sheet
15 pages
Data Analysis With SQL: Mysql Cheat Sheet
PDF
No ratings yet
Data Analysis With SQL: Mysql Cheat Sheet
4 pages
Mauli DBMS Micropro
PDF
No ratings yet
Mauli DBMS Micropro
16 pages
What Is An Operator in SQL
PDF
No ratings yet
What Is An Operator in SQL
12 pages
2nd Oracle
PDF
No ratings yet
2nd Oracle
13 pages
Lecture 05 - SQL Commands
PDF
No ratings yet
Lecture 05 - SQL Commands
40 pages
2 Sorting
PDF
No ratings yet
2 Sorting
16 pages
ANSI SQL Operators
PDF
No ratings yet
ANSI SQL Operators
48 pages
SQL Part 1: Kal@ittelkom - Ac.id
PDF
No ratings yet
SQL Part 1: Kal@ittelkom - Ac.id
41 pages
SQL 1 (Basic)
PDF
No ratings yet
SQL 1 (Basic)
41 pages
Basic Operations With MySQL - Part 3
PDF
No ratings yet
Basic Operations With MySQL - Part 3
10 pages
DBMS Lab 4
PDF
No ratings yet
DBMS Lab 4
5 pages
2.10 SQL Operator
PDF
No ratings yet
2.10 SQL Operator
19 pages
Sql-Ii (DML)
PDF
No ratings yet
Sql-Ii (DML)
63 pages
SQL Operators
PDF
No ratings yet
SQL Operators
12 pages
Oracle SQL - Session1
PDF
No ratings yet
Oracle SQL - Session1
46 pages
Operators in Oracle
PDF
No ratings yet
Operators in Oracle
12 pages
SQL Comparison Operators
PDF
No ratings yet
SQL Comparison Operators
17 pages
Week 4 Practical Activity 1
PDF
No ratings yet
Week 4 Practical Activity 1
20 pages
SQL Operators Oracle
PDF
No ratings yet
SQL Operators Oracle
38 pages
DBMS 2. Restricting and Sorting
PDF
No ratings yet
DBMS 2. Restricting and Sorting
26 pages
Lab 1 - DMS
PDF
No ratings yet
Lab 1 - DMS
45 pages
Database Administration and Management: SQL Lab
PDF
No ratings yet
Database Administration and Management: SQL Lab
38 pages
7BCE5P1-Relational Database Lab
PDF
No ratings yet
7BCE5P1-Relational Database Lab
88 pages
Lab 1
PDF
No ratings yet
Lab 1
40 pages
2 Restricting and Sorting Data
PDF
No ratings yet
2 Restricting and Sorting Data
5 pages
SQL Hands On
PDF
No ratings yet
SQL Hands On
51 pages
Modulo 1: Querying and Filtering Data
PDF
No ratings yet
Modulo 1: Querying and Filtering Data
35 pages
SQL Operators Functions and Keywords
PDF
No ratings yet
SQL Operators Functions and Keywords
9 pages
Lecture 12 DML Select
PDF
No ratings yet
Lecture 12 DML Select
24 pages
SQL
PDF
No ratings yet
SQL
13 pages
DMA-chapter No2
PDF
No ratings yet
DMA-chapter No2
35 pages
SQL Operators: What Is An Operator in SQL?
PDF
No ratings yet
SQL Operators: What Is An Operator in SQL?
8 pages
Lecture 13 - Restricting Rows and Sorting
PDF
No ratings yet
Lecture 13 - Restricting Rows and Sorting
27 pages
Postgresql (The Version of SQL We'Re Using)
PDF
100% (1)
Postgresql (The Version of SQL We'Re Using)
13 pages
1.2 SELECT Statements With Operators
PDF
No ratings yet
1.2 SELECT Statements With Operators
41 pages
Experiment-2: Quires Using Operators in SQL
PDF
No ratings yet
Experiment-2: Quires Using Operators in SQL
6 pages
Day 1: SQL/PLSQL Concepts
PDF
No ratings yet
Day 1: SQL/PLSQL Concepts
66 pages
Lab Manual 2
PDF
No ratings yet
Lab Manual 2
9 pages
2778a 02
PDF
No ratings yet
2778a 02
35 pages
Select FROM Emp : 4.1.retrieving Information From A Table
PDF
No ratings yet
Select FROM Emp : 4.1.retrieving Information From A Table
6 pages
Chaper No.2 Ravindra Babasaheb Nagare DMA
PDF
No ratings yet
Chaper No.2 Ravindra Babasaheb Nagare DMA
34 pages
Logical Operators SQL File
PDF
No ratings yet
Logical Operators SQL File
11 pages
Chapter 10 Where - Order by
PDF
No ratings yet
Chapter 10 Where - Order by
83 pages
Lab 3 Muhammad Abdullah (1823-2021)
PDF
No ratings yet
Lab 3 Muhammad Abdullah (1823-2021)
11 pages
Reviewer
PDF
No ratings yet
Reviewer
6 pages
04. SQL Queries, Clauses and Operators
PDF
No ratings yet
04. SQL Queries, Clauses and Operators
12 pages
Database Systems Lecture3
PDF
No ratings yet
Database Systems Lecture3
26 pages
Lab Manual 02 (Basics)
PDF
No ratings yet
Lab Manual 02 (Basics)
8 pages
Snowflake PDF
PDF
No ratings yet
Snowflake PDF
93 pages
SQL_PPT1
PDF
No ratings yet
SQL_PPT1
125 pages
Operators (Oracle)
PDF
No ratings yet
Operators (Oracle)
31 pages
Operators (Oracle)
PDF
No ratings yet
Operators (Oracle)
33 pages
1.1 SQL Operators Overview
PDF
No ratings yet
1.1 SQL Operators Overview
6 pages
DBMS Template 2
PDF
No ratings yet
DBMS Template 2
6 pages
SQL Server Basics Part One
PDF
No ratings yet
SQL Server Basics Part One
8 pages
SQL SELECT Statement
PDF
No ratings yet
SQL SELECT Statement
5 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
SQL Cheat Sheet
PDF
SQL Cheat Sheet
Data Analysis With SQL: Mysql Cheat Sheet
PDF
Data Analysis With SQL: Mysql Cheat Sheet
Mauli DBMS Micropro
PDF
Mauli DBMS Micropro
What Is An Operator in SQL
PDF
What Is An Operator in SQL
2nd Oracle
PDF
2nd Oracle
Lecture 05 - SQL Commands
PDF
Lecture 05 - SQL Commands
2 Sorting
PDF
2 Sorting
ANSI SQL Operators
PDF
ANSI SQL Operators
SQL Part 1: Kal@ittelkom - Ac.id
PDF
SQL Part 1: Kal@ittelkom - Ac.id
SQL 1 (Basic)
PDF
SQL 1 (Basic)
Basic Operations With MySQL - Part 3
PDF
Basic Operations With MySQL - Part 3
DBMS Lab 4
PDF
DBMS Lab 4
2.10 SQL Operator
PDF
2.10 SQL Operator
Sql-Ii (DML)
PDF
Sql-Ii (DML)
SQL Operators
PDF
SQL Operators
Oracle SQL - Session1
PDF
Oracle SQL - Session1
Operators in Oracle
PDF
Operators in Oracle
SQL Comparison Operators
PDF
SQL Comparison Operators
Week 4 Practical Activity 1
PDF
Week 4 Practical Activity 1
SQL Operators Oracle
PDF
SQL Operators Oracle
DBMS 2. Restricting and Sorting
PDF
DBMS 2. Restricting and Sorting
Lab 1 - DMS
PDF
Lab 1 - DMS
Database Administration and Management: SQL Lab
PDF
Database Administration and Management: SQL Lab
7BCE5P1-Relational Database Lab
PDF
7BCE5P1-Relational Database Lab
Lab 1
PDF
Lab 1
2 Restricting and Sorting Data
PDF
2 Restricting and Sorting Data
SQL Hands On
PDF
SQL Hands On
Modulo 1: Querying and Filtering Data
PDF
Modulo 1: Querying and Filtering Data
SQL Operators Functions and Keywords
PDF
SQL Operators Functions and Keywords
Lecture 12 DML Select
PDF
Lecture 12 DML Select
SQL
PDF
SQL
DMA-chapter No2
PDF
DMA-chapter No2
SQL Operators: What Is An Operator in SQL?
PDF
SQL Operators: What Is An Operator in SQL?
Lecture 13 - Restricting Rows and Sorting
PDF
Lecture 13 - Restricting Rows and Sorting
Postgresql (The Version of SQL We'Re Using)
PDF
Postgresql (The Version of SQL We'Re Using)
1.2 SELECT Statements With Operators
PDF
1.2 SELECT Statements With Operators
Experiment-2: Quires Using Operators in SQL
PDF
Experiment-2: Quires Using Operators in SQL
Day 1: SQL/PLSQL Concepts
PDF
Day 1: SQL/PLSQL Concepts
Lab Manual 2
PDF
Lab Manual 2
2778a 02
PDF
2778a 02
Select FROM Emp : 4.1.retrieving Information From A Table
PDF
Select FROM Emp : 4.1.retrieving Information From A Table
Chaper No.2 Ravindra Babasaheb Nagare DMA
PDF
Chaper No.2 Ravindra Babasaheb Nagare DMA
Logical Operators SQL File
PDF
Logical Operators SQL File
Chapter 10 Where - Order by
PDF
Chapter 10 Where - Order by
Lab 3 Muhammad Abdullah (1823-2021)
PDF
Lab 3 Muhammad Abdullah (1823-2021)
Reviewer
PDF
Reviewer
04. SQL Queries, Clauses and Operators
PDF
04. SQL Queries, Clauses and Operators
Database Systems Lecture3
PDF
Database Systems Lecture3
Lab Manual 02 (Basics)
PDF
Lab Manual 02 (Basics)
Snowflake PDF
PDF
Snowflake PDF
SQL_PPT1
PDF
SQL_PPT1
Operators (Oracle)
PDF
Operators (Oracle)
Operators (Oracle)
PDF
Operators (Oracle)
1.1 SQL Operators Overview
PDF
1.1 SQL Operators Overview
DBMS Template 2
PDF
DBMS Template 2
SQL Server Basics Part One
PDF
SQL Server Basics Part One
SQL SELECT Statement
PDF
SQL SELECT Statement