Ne] elmsy sto
ce oe
eee ees
ee eee as
en
eee
ee ee
ee eee ee ence ee
Ce Ce eee
eC ee er ee ee
fee ee ete
or eee
a ee eee ees
or ee ee eer eres
ee ce eee oy
ee eed
een ese are een
nee ee
REPLACE() ~ replaces all occurrences of a specified string with
‘nother string
Ce en
eee etary
ee ee ed
fee ee ees
coeenes
(CURDATE() ~ returns the current date
CCURTINE() ~ returns the current ‘ine
ar ete ee eer eee
DO ee
Do ee ee
DATEPART() - extracts a specified part of @ dote/tine value
Ce ee ets
Se td
Ce en et ero
Soe et eee ees
eens
Ceo
Cen ete ee eee ete Sear
er enn er eee ey
St enn ener
cree
ee ee eee
Cee a eee ees
coeeses
cen ee een Stee ee ess
er erst
Ne ee ek eC coe cd
ree an ees
Ce en eet css acc re os
eee ere
Ce ee eC Cee ne
the First table being paired with each cow from the second table
ee eC asco
Ore eo
en eae
cSt d
INTERSECT ~ returns rows that are present in the results of two or
ee en end
ee ee ee ees
evernees
See ee ee eas
ood
eo oe end
ered
WHERE ~ specifies which rows to retrieve based on certain conditions
eed
ee ee ee ene ce)
Po eee ee ed
HAVING ~ Filters groups based on a specified condition within the
Sd
Seon cere
Se ee eee eee
ns
ees eee ees
TRUNCATE TABLE - removes alll rons from a table
Cee een
er
Cee es
ee eee aed
Cee eee eases
Sea ee eee
See eee ee eee er
ees
See eee Cageo eee enh cree stray
eee SCR meee
Corea
eee ete teeec cots
This type of join automatically matches rows
ee eee eres
Core ue a)
Ce See eg
ora
ee eek Sea tene st et
ee Cee
ee ee etc es
faveeesty
Right Outer Join with Exclusion
ety
See eee
Se ee eee
Ce es ace
Se cn ocean
eae
eee ecto
rere
on cere ees
een
This type of join allows you to apply a table-
Pees ints nec Esc
Tr
Gin em anise ter
eck eens
Ce
Poon
eee ee Ce Cee
Pete ee
enc eee
Fo ae end
table that do not have a match in the right table,
Cee
eee Oe
Pca
opens
Ce eee Cee ene eens
aCe
ea
Po See ees etn s ee teees iors
eee ee eee eee
CC Recs Sg
ec eee
NS ne eee
Cece Cree or iy
ee ean
This query will return rows from all three tables
that have matching values in the joined columns.
It will first join tablet and table2 based on the
Se ecu aee ad
Preece
Patan
Come Cmte ck eS ke ote temr st kayy
LEFT JOIN table3 oN table?.col3 = table3.col4;
es
a Oe ee ae
Roe cna
Poe ae ee
Pe ee cee neee oc ests
etme)
Pn) | 5000 | 2670-01-01,
ec
oes | 75600 | 20
Ce ce
Pr eens
cae ee a reese
aia cee ed
Pan oe ec ed
Par cee Ded
rary ons | 4000
oar es coe ee)
oan ee eed
Par) a
card ore erased
oar ee ee ed
ae ee eed)
eee erate
ac
a ec)
a a)
ee)
eee ce Coy
Cy
ree ore ee es
Fe ee eS
sorted by salary in descending order.
ae Ce ened
Se ee ee ee as
eee ng
ee een re eee en ces
Se ee eee ees
ees
See ee or)
Ce ee
ae cre en mStar. ory
eo Cr ere eee
ere ed
See a eee oe eI ec)
Se CLE
ee eo oo a eo
Pee Reon ht eon ee ena
rea ee eee
coal
‘6-Retrieve the name, product, and sale amount for all sales in the sales table that
‘occurred between June 1, 2020 and December 31, 2020.
Pa ee roe eo
ee eee ert ee ee
eer ee enter eee er eter
‘7-Retrieve the name, product, and sale amount forthe sale withthe highest sale
‘amount inthe sales table, along with the corresponding employee name fram the
oar
Po eee or ee
Pore er ee re Een eee eas
eee ee oe een
sales);
Ne a ea ae
‘sowing the name of the manager from the employees table as well
pone en ee eer Cac oceans
See ere eer
‘9-Retrieve the name and number of employees forall managers in the employees
earned
page aOR On ones
eee cre eee eee
Sea oe ee aed
ces
Se oo rae
CC ee ek ker hey
1 4-Retrieve the name and total sales forall employees inthe employees table
Ce ea en ee et
a ote komo t an ors
ete ee Cee a
CO OR ee eee
eee
ty
i eg eet
(ch To) ee eee
Cam ce eee
Cia
(oltTaag
oc a en ee
See nen
Oona
ee ee eee]
Ce ee ee eee)
CeCe ee
econ ened
FROM and WHERE clauses are executed fst to select the relevant rows from the
Oe eee oe ra
aggregated using the SUM function in the GROUP BY clause. The HAVING clause
fiters out any groups that do not meet the specified condition. Finally, the SELECT
clause selects the name and total sales for each group, and the ORDER BY clause
sorts the results by ota sales in descending order.Cee oe
to perform a certain action, such as querying hierarchical data
cee te
Cad
potas
Ponts]
red
5}
Se ee ue eet
eee ee ere ee ents
oes
are en
ae OCC oom Ree
cones
cones
Se Ca ee ee
Ce ani en eee aD
statement. They are often used to simplify complex queries by breaking them up
oe ees
eee
ns
poe
>
Ce ae ee ee
ee ee a eo
pe
mete
aad
Euan SUE)
Poked
5
Crag
Earcooy
Oem OR)
ds
Se eee ee eee)
‘group of rows and return a single value for each row in the result set.
pera
Poe ee ere Ree
oOo
ones
De eee
response to certain events, such as inserting, updating, or deleting data ina
is
Triggers:
Cn eed
ss
ey
cont
ec
Se nee ec eed
stored in the database and executed repeatedly with different parameters.
=> Stored procedures:
See eo ed
en)
Peon)
eed
co
Co kod
Se ted
‘of certain types of queries by allowing the database to quickly locate the desired
oan
eee Coa ae
Cees
{9-Cursor-based processing: This i a method of processing data in which a
Breer enero ee tat een tees a
rows, and then retrieve the next batch of rows untill rows have been
processed, This can be useful when working with large result sets or when the
Sree eee
~~ cursor-based processing:
Ce cae ae
oes
Coe
pe ee
col
processing code here
ee a eee
Ce
Seren rey
@SteveNouri