0% found this document useful (0 votes)
15 views

SQL-Basic-Cheat-Sheet

The document provides an overview of SQL commands and data types, focusing on advanced filtering techniques using comparison and logical operators. It includes examples of SQL queries to retrieve employee records based on specific conditions such as designation and salary. Additionally, it outlines the structure of SQL commands for data definition, manipulation, and control.

Uploaded by

MADHUMITHA A
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

SQL-Basic-Cheat-Sheet

The document provides an overview of SQL commands and data types, focusing on advanced filtering techniques using comparison and logical operators. It includes examples of SQL queries to retrieve employee records based on specific conditions such as designation and salary. Additionally, it outlines the structure of SQL commands for data definition, manipulation, and control.

Uploaded by

MADHUMITHA A
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Multiple Conditions

SQL

asi Query
B c

With the help of comparison operator, we can perform


Sele ting ll T e Columns
c A h Sele ting Spe ifi Column
c c c advanced filtering in numeric or string values.
Select from m loyee Select Designation from Ta le name ogical Operator

SQL Basic Cheat Sheet LL, ND, N , ET EEN, E ISTS, IN, LIKE, NOT, O , SOME
* E p b _ L

Output: Output:
A A A Y B W X R

Get the employees records whose Designation


mp_Name Designation Salary Designation contains ‘A’ in it also salary is greater than 50000
Employee Table Data Types for SQL
E

Smith A nalyst 55000 Analyst Select from m loyee here Designation L K %a%
* E p W I E '
Consider the above table for all D Salary >
the examples given in the cheat Numeric String Date Jason Designer 75000 Designer AN 50000

Sheet Data Data Data


A n rea
d Sales 35000 Sales Output :

E mp_Name Designation Salary Types Types Types


Bigint, Char, Date, mp_Name Designation Salary
Smith nalyst
E

dvan e Filtering Query


A 55000

Smallint, Varchar,Te Time, Smith nalyst


Jason Designer
Sorting e ords
A 55000
75000
int, xt, nChar, Year, A c
Get the employees records whose Designation
R c
A n rea
d Sales 35000 Tinyint, nVarchar Datetime,
Decimal Datetime With the help of comparison operator, we can perform contains ‘A’ in it or the salary is greater than 50000
Sort the employees table in
offset advanced filtering in numeric or string values. ascending order. Output
Comparison Operator

SQL Commands =, >, <, >=, <=, <>,LIKE, IN Select from m loyee
* E p
Select from m loyee here Designation L K %a%
* E p W I E '

r er y Salary SC Salary >


Get the employees records whose salary is
O d b A
OR 50000

Numeric Data Types equal to 55000 or greater than 55000 Output :

E mp_Name Designation Salary


Data Definition Data Data Query 
 Data Control 
 Select from m loyee
* E p
E mp_Name Designation Salary
Language (DDL) Manipulation Language (DQL) Language (DCL) W here Salary > = 55000
Smith A nalyst 55000

Language (DML) n rea Sales


Output
A d 35000

:
Jason Designer 75000
Create, Alter, Update, Insert, Select Grant, Revoke Smith A nalyst 55000

A n rea
d Sales 35000
Drop, Truncate Delete E mp_Name Designation Salary Jason Designer 75000
ample ample ample ample Smith nalyst Sort the employees table in
asi Filtering Query
Ex : Ex : Ex : Ex : A 55000

Create ta le b Upd ate m loyee Select from


E p 
 * G rant Select, Jason Designer 75000 descending order. B c
m loyee S T Salary m loyee nsert, Delete Select from m loyee
Get the employees records whose here
E p E = E p I ON
* E p

(m E ame
p_N 35000 w here my T db O
r er y Salary D SC W The here cla se is se to
: w u u d

Designation contains ‘A’ in it.


O d b E

Varchar( ), Salary ser localhos filter the ta le horizontally


b

Output
25 = 25000 'u 1'@'

Designation t ';
Output :
Get the employees records whose
salary is 55000
:

Char( ), Salary
25

nt)
I Select from m loyee
* E p E mp_Name Designation Salary
W here Designation L K %a% I E ' ' Select from m loyee
* E p

Alter ta le b Delete from Select R e oe v ate


k Upd
Jason Designer 75000 where Salary = 55000

m loye m loyee here Designation from Sales


Smith nalyst Output
E p e
E p W ON

Alter col mn u Salary < 10000 Ta le name


b _ F rom L RO E_A;
E mp_Name Designation Salary A 55000
:

Designation n rea Sales


Smith nalyst
A d 35000

mp_Name Designation Salary


A 55000
Char( ) 30 E

n rea Sales
Smith nalyst
A d 35000
Dro ta lep b A 55000

Em loyeep

You might also like