MySQL Cheatsheet
Database
itis defined as a collection of interrelated data stored together to serve multiple applications
MySQL Elements
MySQL has certain elements that play an important role in querying a database,
Literals
Literals refer to a fixed data value
a
Pace eee et cto
Data Types
Data types are means to identity the type of data
coer
EG eR Ty
Doe
SHALLINT
Porch esc)
CnC eta en ee ec nee acer
cent eet eno ears
Peer
eos eae}
Phaedra ec Sete Soret eae Te
ee cree se MCT)
coeur
CC eee
Se eRe eee e ESTs
eo
NULL Values
Ifa columa has no value, then its said to be NU!
CommentsWorks Where You Write
iy offs sugges e
Grammarly
ess a sangue-nine commend
Pe eee ees Cetera
MySQL Simple Calculations
You can perform simple calculations in MySQl, just by using the Select command, there's no need to select
‘any particular database to perform these commands.
Addition
Ik will age two numbers
select 5+8;
Subtraction
‘twill subtract the second number from first
Multiplication
Ie will give the product of supplied numbers
Division
Ie will divide the number
Stree
Accessing Database
‘These commands allow ane to check all the databases and tables
‘Show command
It will how all the databases in the system
It will how athe tables in a selected database
coments
Use command
It will start using the specified database Le. now you can create tables in the selected database
ccdThis query is usea to create a table in the selected database:
Pee See seers
tee ee
Poteet e
fr roescsy
Insert command
It will add data into the solectes table
PCRS SUR em Ccotisteiss)
Sener ete one
Inserting NULL values
This query will add NULL value in the col3 ofthe s
eee sees
Cotman
Inserting Dates
twill add the following data into the selected column of the table
eee SCR emcee
Select Command
A select query is used to fetch the data from the database
Selecting All Data
Iwill retrieve all the data ofthe se
sd table
comes
Selecting Particular Rows
Ie will retrieve all the data ofthe row that will satisfy the condition
eee eee
Perr Comet
Selecting Particular Columns
Ie will retrieve data of selectee columns that will satisly the condition
Patera er ecrecist
Pere ee eee ees
DISTINCT Keyword
Iwill rotriove only distinct data Lo. duplicate dats rows will get oliminatedeee
Column Aliases
It is used to give a temporary name ta a table ora column ina table for the purpose of a particular query
Sreraecestrey
ees enrey
Condition Based on a Range
twill only retrieve data of those columns whose values will fall between valuel and value? (both inclusive)
aerate
een
mere Between s
Condition Based on a List
See eee
Sete RC eeeenaTe!
otras
poecstt
casera
elect