0 ratings0% found this document useful (0 votes) 92 views39 pagesMysql. Notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
&
Mes
H
oe
which makes harduwaye work
“te
yo
cycle Follosre ¥ pplicce
ton Sot liao
Cucer eLohlwore )
af
/ t ;
operating seem hg Preqramer
Dhanguage *- eH te othe Communication ovedtugs
ble wo peacons (ow } pesson and i
Languages
BP ee dy aoguage
c ev. danguag
: BASIC
| itdtkine hee CoRal
| We, 0 FORT RAW
leasnin: ” '
rid HH Cones | Pautcad
N consiels on Small english e f
o'Sand {8 called Commarde, yihon
LF Cony dg) eh sn
| add,¢ub yr, \
SM, prin
GL Called mnemonicseosladons 2. These Programm are ved +o
convert Se Progrrarmente« wrrtlen in one Dan
in 40. another Janguage
q ¢ ft
wet * ; I
1) Assen bley 9) Solerpredley 2) Complen
eae fog High level to High level Joop
~inge to rh machine, ~e lo machine
‘e leaaining Yan age, Ley
is
Jacquage Chine by ine ) ae fn ey of
BASIC » Beginens all. puspace Symbolic, inslructio
COBOL > Ccrenen butinets oriented a
VB > ‘Weil Basle " fe
for-brany—s, formula
“banmigeion
operat n raat Sycler be Oke an infeguated Sef
of ing yuclions. «that govern Control 2 Cog
~dincele | he Computer fare d Soblasave,
ord alo act aC an ‘ntexpretes bho he,
Uses oie the
ee
oF ean
Ging @ ask
(28m) giitas ask cacple)
&F Pel oe Cee) Loess AP
Cat Untte Geo)
LINUY Cavell
INux VOWSF Gv! > ye Phicah Kiser Wallace,
-evr> Command v
» TUL? Termin)
“
Root frg 5. Nis she Procec al Joaclieg Leopyi
_ othe opercrting Syclem Coyslern ier) lo the
pote main memory C Ram’) eam an
erlernal Borage device Clad dick)
Booting '
cold booing LCurQentn tadl
(Power ov) € reslaoet
6 Boer 9
FD Uiflidy Programs 3= Thece Prograrns: ave worlly
th by the manufactune, low o specific “luck
Such as Cat) Copy, pale: gaye, open print al
Application programs “Thee pegrom ore unit
oy the ster or o quen ogk. Such Ou
a Calculates, game Cor) a user ovr Cucing @ |
selected Progamming Janquoqe)
Tes of pple +Applications |
—— Blandalene Network based
Conde appli cation, ¢_{( vu ae
Windows © Cron at decly
yay Web», 1
_ Gun af lotvoute,)
Netuork $ A Sel of Computers Connected toned
sor he , Puxpove of Shaxing foforrration (emo,
le oy a Program) 4 aecources Choad cick, Prins
Scanner) % called oc network.
Wess of aly : iis
© Xo Pegy tn the type the “alocla %
Lloved focally in. riespective Compuclery there
VIL be nok be any fall Ourthorry over the
Stoved lola oy any . dingle. pexton 0% any
“Machine ,
CNent [Renven & n-thit “lupe ~the enre ola
%) Bloved 8A one main Computes calld a
Seiverand will have full outhorry over the
Bloved olata .. the Computers. “Connected ~o- 3
do access the data ave Calledac client J
Will rave Tiled occes viet vex the se
dalaEee
te Jeninglogy oe
O bANS hota) ‘avea nlw
sthe. axea of clhis he Spans with in a batting
oa Compu that is lees than, LKM,,
CArtlenna 4 Cable) ;
© Maus Metropolilon oreo nw .
the onea of ~hi nly spars acvets the ,
melropollon cities Grawesy ¢ anlenna's) ;
® WAN - Wide avea nw
The asxea of thie nw spars aco “he. 3
ola Cscdililer b 4owess )
Nie Sepadegieg These ave the Del
“scatplione of ~the way compuclent . av€ Connect
~ed in a nlw
z Coble 5 No -Veret for 0:0!
0 But Ap EE Z ze Z : Compuctent :
iat gt a
Rings : =} [pietit Love no. ét.
C5 3 computes :
Cable
=> ove Chances of
EA Vent toy No foe lus break dow
des Chances of Dhw breakdeor
@ Blan7@ Gree +
Se 7 ° te fes ‘a
‘ a Cor
SIH al fereloud.
cull comple
“thece awe folnd lo point "
Pop > post office ”
SMTP > Bimple mail transfer x
QSnrP> syechroneut type 9
HTTP Hyper +f et traned. ”
rep lop Hype He chen
~> Transmiscign Corrtrol frotoco tre " al
Ortesinet Geom Ox
DDYwnw wae
earch gM finds ot thle ‘nthe computen ov
web poge inthe Wlernet. Cet gol, ypheo 6
askme.. .
Browse = 91 Linde dad alto. opens ae
~the Computer or web poe mete ce
OU" Anlenne! Cuplover , nelecape raviyelon,page Web Page eM a
uty a raskp barge men Created fy,
i Such as 4CIML (
Aer MOAKUP fan H99¢) ~that open | a
on™ fen A oO Yeh
gHlelwebste ° 94
Ph outa t © a Collecdian ol web Pager
sat ee blus therm wing Wy per links
& / Page +Home Page | Graley page % O's the
O92 in 0 website :
WWW> World iotde Wel,
M Ne ~the Syronyrn efor the intesnet
W3¢c * boonid wide web: Consowiuny Ot io the’
uliog body of he Swteanet,
Hlomain Name $ ot ig the name of He welile
ov ~the Computer ashere It o1esih kuch os ~t
Port number $= 94 is an inlegen value that uly
flentlies a compuclex in the lus uch at
docal hast : 1566 Domain name
URL 8 Unto Resource hocater. SL ty the
adess ov path of a tie ‘nthe Computer or
i \nleaned
A WebPage in he ,
3) oeawte uae te cab deed thd a
, qo
the tool lye eller Such as cclcesh
A NOW -” b) Relative VRL g path ped thy thot include i
only’ present working atvecHty Such as
images cuties
ees A warbler s+
-com — | Qushnes
eg
. e! (ov) : Lntestai ment .
é mil Rnbormation
. nel
“ine
SSR ~Jnlernet whee provider
Gtk oo Comnfony that provides -the ‘wleane
-lo she end ucen ‘
Qownload Copying an ‘hem from tatennet -
loco) cornpucter
Upload Copying an Hem rom loot Compr
40 ‘nternet.Ok (Sele due ee
Ques: han
mA nn deg )
» LOb fs the Slo a wwe
alela base sm, rina Jorguoge bor Stelerheng)
-ned by may ore “ser [ROMS a dh
spdltlede, mearean nationa) larch)
2 SOl was cleye
Busine ge Mae
HH imple
langdage
> SOL com
loped by 98M Cinlernalsnal
hine) \n “the Year 1944.
yet powerful non- procedural
fox Commnurieating with doca braces
Marcle aye broadly Clasified Pr Yo
5 kub Danguager 0 Senne ,
) Ok (Rata Relnalton language )
CREATE
ALTER
DROP
2) Om (Roca mart
ONS€ RT
bPDATE
Detcte
3) Yh (Pransacd
p ulotion Danguage)
(on Conlyol lenquoge)
“hese Commands ave uted lo Contra! Lhe
-hansaction Comet opextion) made +e te |
dota pase Server fron the Chent applicaee “caicelling the
DML opercttion
COMMIT | doviny
ROLL BACK
4) Hew (Rola combral language)
Chere Commande ued lo “control the dota
amang dilfesient types of user's of dalle bag
GRANT ving Cov’) Taking back previlage's}
Revove } 4 3
5) De [PAL CAala kelvival] duery languose)
S@LECT. ‘
| Shy Clauses % Thee ove-he mall english
stenms ued lo build [cree "Sab Quexy!s
Klalemerd's
PROM ORDER BY
10 GROUP BY
aS HAVING
VARVES
SET
WHERE
oN Operalore= operators ave -the Spe cla
Chesiaclens @® Keywords thal pestovm «
spercetion of one a more opexandsEe
a Czaabh
abe opercinds
+t > openctlary«
A yR
add lton, Asclyn men “s “me
9 tion Aailbvnalicad AFAR &
yo addition
— >Subbachon |
> Malliplicadion
J ~> Rivision
@reriesh oppelen,
AND ‘Sogical AND
oR logics! ok
Not logical No?
Mh eh ectov (=
@ coveltional Com PAAR Opera
= > equelt to
2 > lescthan ,
Ze qrrecrer-than
z= ~> tess-than ov equal to
>= > qrecler than ov equal to
24> > Mot equals toB felstinned operate
(Mot ON [ea vepreserth optiong)
aa operators
Coot] BETWEEN Ah eprecen rey
q aaa, uf
[no7} b1Ke Oc. i
Tuo) Sxtete 0 With ov toHhout
Poramelexs
Trot} ALL <-> Deprecent usen
RCNOT] Nutt | a names
NEE There Lymbolt only
meant fov urdes ela nin
the urlan’ not for,
~tying
© $7 genedens
There operclors ave uted bo Compave. ov
Combine the data of tu | sfrrilan
slables (Same definttion’)
=akk Foy table 8
| =
| ONION t settldens gelums “the dala of wo
-tablec of only distinet Toes
UNION ALL ¢ xelums the deta of -4as0 -fabk
I
ot o all Seow!ry ee Toe Fo are R Sect & metros the Comma
A (Xv) WY
yous of -teoo lables
Minus & oelurns the 510u% of one
iE oble thee nol exiel in other
-lable
©) Concateracton apenadey -f- CAdde Lua Shing
+ OF 4, Campeuand)
Redo ty Pes %& A clola ype defines the lupe of
dela user ‘can Glove in-b a voutiable (ov)dela bar
Column
our type vaxtable name; -
int — Sno3
(or)
Column—name ype;
Sno | int; a
%) CHAR 4 defines -the Column af chavacler lye
HE Can love upto aco Chayacler; default %¢ gor
Lk & -Sname chav Co) 5 ( ;
genden chery | SON
3 Mt padded dale fype
> Oh fs used with tinted length Columny
TH) vARCHAR % G4 also delner the column’ ar
_ Chevacler ype but Con Glove upto ceo Charadlez
£x% nave Vaschay( lo)" teayanud!aS Ob fe non padded hata ‘pe
=> THEW used toitlh voorying length dey dd th morth yearBMS & Pata base Monagerent ' yeti mn
4 fe manipulate \n
Pala ave the Pescls
) Combiner ton
e
computer ave’ ches
Lon wW-the -forrns of deta.
and Conciels of numbeyt, lero
of two.
> A Relabase Cons\tls of all ~the lec of an
ovganigection that 3g. a collection of Slowed
operational ata” Cqvsittied deta fow a. Poslicul
jack) used by the pplication SyHems of Some
particular entenprite.
DEMS gives ut a toy of qatlering epee,
gpecilic pieces ov licks of anformectio that are
selevarl lo us th our fobs ov fives ond
alse tt provides a Way 46 clove and maid
taformation ‘on central place.
Alternate Texminalogy
Froditte not “Lommron Reler tonal
Fle ‘lable > te gelationa) ' L
recovd You tuple is
field Cell — -atluibule
Value value ‘nance:
Most popwlas PDBMEStn-the swovld -feday
DEP ABM HR2CMaintvames ) .
oracle
gybace [Sat Server)
MS ~SQLISoveyy
rnulCm Teeajon)MYSQL 8S an: opem ~ source aelotiona) dcx
manage ment Sgt (ROEM) GAS Name’ Py q
Combination of.) My", the name of Co-Foond
michael wi denius's chnlgh le, and "Sar" the
abbreviattan for sructuwed Avery Jonguaye
Nesslone% the fil yesctan of Mys@L appears
on 93 may, \aa5. : j
5.1 20l3
By 2019
Se Do
Bt 2023
80 2026
SHOW Command = This Command 's used “fo
kel the Hems ms pretend in MALL doa bas Se
Syntax!
yon CHow dala baset 5,
tov)
SHOW Fablecy
Creating g delabae %
ween YN Wr
Syntax
CREATE DATABACE Zolcdabcue names}
OE nytgl S cyecele lala base mydb 5
wey 9 delete:
syntax = Use Zdolabage —name >!
Cem mycg}y use mydb,PRN TEN Sere & Inlegntly Carthy
bls ave the stulles we Can define 0 a Callin
ns to Move ~the deta of Parrliculas “ype
Thee Comyatnds ave broadly cdactilied sa fo
3 types swthey ane .
1) Qomain integrity Contlyai aly
> Not nlub
> check le
9) Check ality Srlegrity Come rls
~> Unique
~> Primay key
& Refenenti’ Inbegthty conglrainde :
> Gierple siefexenty 4 wed Jo bind-wo
~ foveign key " slaloles wrth Srebadtion
“thip Condition
Primo Key eo hs the mac wnporlant type
of all ~the Contyainle. P+ is acitomelealy
indewd In moet of the Nemes.
»U can be dedined only once ina Yable tse
a table can have only ‘one Peienaty ‘Key
defination
Creating a table ¢
vw. ad vwown
Syntons= CRcATe TABLE Z table name> C
Colum data type,
is 2 * i P,
\
NN ]| Gt Greate a table -lo Glove. the Chdenty 1
infowmertion~ thay may Coneled Id Mame ,Coure
J Myegls cvectle lable sludenl~ Into C
~SNo Int not null
primary Key (ing),
Sname Vaxchan(i6) not nulls
Course Voxchan(n) not-nulls
dof dete ,
fee decimal (8,2)
dy ‘ hon
DESCRIBE Commend ss It is wedte dlecnibe
Gre table” definition
Symlone = pese [RIB E] 44able name >}
| & mysg) sdece. Stud-into 5
Entering the dala %-to—the dole
Sunda %
ce et DATS Zablenames
Cecoturnnl, Cdumad, ~~ J
yarves (valuel, value 2). 5
Be my co dinvert Info Slud— into
to
value C1, ‘aut | ‘python . ‘5a og ia 350d)
Voluet(2, chinlu’, ‘ovade’, ‘22leshia’, 500)SERA ROMAN SThis Command's Uted to ©
gelvve ~the decla som a -lable, atlen bared
of 2 Creag
Syrdax cor poy J Colwen, Coron 7
all Colurang,
FRom 2 dablenames
© [we Re Cablesia’] j
Lee muycaud + celect from glud— into}
pCveale onclhen able -lo love the, Stederte
maskt that may Consicle
a, 3 Sub moat,
BEN and’ yubtege” Vue! ie shy
mpiql_>Creale lable slud-masks
Sng int seferences
ctuduinfs Cio),
mankaint, w { i
makes ‘int,
Manks int,
average decimal Cu,1)
By uli
2
ingegl> et into duinlo .
vyadues (1,53) U5, 63, MALONE
He raat!
7 i sade Stud-infe (ero,
& nyo! > Merle ito Ne 1 eh)
values (> 35, Ub 54)
UPDATE Command & wed to update “the
values ‘in & Column (oa) Columns In a lable
ae ee a eeeD Systane r
UPDATE ZAablename y SE
Colurnn \= {value leapreision },
Column 9 > 4 value eXPrestion ,
\ a
Cwhiche cvileriay,
Gat updale “the column -lolad with telat
| many
mnystel supdete shadmarks cet .
wave otal = marks emarks 2+ Man’ 3 5
PR update she column coverage Mth, averay
ee
marke :
| mug > update sluderaskt cet ayonoge= Ht
Eez3 update the columns -lolal 4 average
mysy Q > update Gludmoaks set
otal = moat! Arnake a + maxkt3,
average = (maxktiamankso tmaxke 3)|
Gey updade +the fee ola cludent to 400
mydgls update udant Tato set -fee = Coo
WWERE whee Sno = 3;
Exr5 update the fee of a Gludert by 0
mysql Uplate ude info Set
fee= fee + 200 where gno=3)Tpetete Command. 3 ~the command, %s,! used J:
Semove ~the dala from a lable OHey
a en a .cydeata
ax >
SY DELETE FROM Z table narnes
: Tuaere evtera J;
E#r\ Remove Whe Aecord of o dudent
whose, Wd 4
mysql > delele from lud-into
whexe Sn =35
git> Semove he secovd ofa student Wha
name is akhts
mysqd Sdelete from tlud-‘nto
- where Sname aki]! Couvie:' py
AACE Cornenand 2 Tks, Command. i ‘Used
to ghtex the ~lable definition, Such as
adding| mock fying ravemaling
Column¢ ov constraints
3 Addin Column« &
Cnet ALTE p TABLE Ztablename 7 ADD
Column datatyfe---
EL add a Column to the fable ud—ir
low slowing phone numbers ,
musa) Salley lable Stud -info add
Phone Vosichan Cis)5| > Modi Modlin Column Caluenns ¢ oo”
Cylon’
ALLER TARLE Zable name y monty
Column datatype,
%% Weyeage ~lhe tonglh of os Colurnn 9 |
she able tude Into: fox toring
MYspl > aMerlable Gud info modify
| Srame Voothax (p03
=> Dropping Columin §
© Syla %
ALTER TABLE Zelable name S DROP
COLUMN Column, name - ~
as Brop the Column phone Prom the He
Stud— info
my Gly able table Stud info daop
Column Phone 5
TRUNCATE Command & Thi Command ty
used -fo vemove —the dela from a-table
Syrlarte _ ~
| JN TRUNCATE. TABLE e-lablename vy
| Pillerencer bhs detete and trundale tomn
4) Pele te Command Can be uted +o vemove
only selected our from Ihe toble
Cwotth WAC RE Clouse): -lyuncate carnmendwemover ali rvours “from “the “fable
9) Mater uring deleling ~hre commana
We Can yoll back the —bansaction
_cewuncatin ng Command aurlomatical Ny ‘coments
wh the —hancaatle 9 "
it) Delete Command ~lo bec move sbereafts
te yemove all mows trom the “ele
Cwithout Lonere. Clause); temcele, Comm
nd makes PL FA one a Cefep). |
DROP Command ees le ie an 1 objec
for, he Cenven,
ma (ms
OY ne DROP TABLE Llable names...
») Duplay lhe dela of emp lace iN
A4Q2
mysql > colect om emp phere emPnd = 408,
38>) Drpllay “he dela “of” emp Whose depilment,
mgipll > Seleel €-Fram emp where deptns = 303
Qs) Display she dota of -talle emp -wWhexe salany
fo lesethan 2606
mysol scelecl & trom emp Where sal 2 = 2060;
Qu) Pieple she doda. of toble Keme vehetel
name % smith
inyigl > cel ecl at from emp Where ename> “oMttY ) Display =the dole’ =lalole ad emp Whow fob
is Clerk 4
mytgl > select Lvarp
,\
Qe) Pteplay ~the data teble ab emp Whore Foine, ;
bed owe Guly i |
M4y6g9 >Gelecl (vom emp whey Keredaber <
“@iloel202
9) Replay “the alata" able of emp howe nee),
Working os Clerks depk 20
MYSYD x celect & from emp —
where Yob= crepe’ and depkno= 0)
8) Huplay the oles of table emp Who ave work
~N9 ob Clakt and Reined before uly 1
MySql s select from emp :
whee Jobs cere! ahwedate = eiloc|aa,
A) Qiploy -the dota of table eme Who ave tn
dept gq 2 getting alaries tethan 2000
myegd > celect % vor erp
here deel ng: 26 avd galiasrece
(6) Display -the dataof table emp who are
gery Salasyy's qvealexthan 9000 V teat
2000.
mys) > Select Hom emp
where Gal S=2600 and sal 2. = 20001Con)
mycyl>celect & trom emp ey
Whene cab belween 5000 & 2000 |,
) Display. Bot emp Whowe aye workin:
cles afd Anal yet 1
mysql scelect "From emp
whee Jol= CLERK’ ov %ob> 1 qnan¥ST?
Cov)
where Jobin Cherean’, 'aniatysr')>
12) Dispay asovk emp who has Boned iA the
year @t>
mysy& > Select & From emp
Where kyedele = \ gylotlor and Rived abe =
catia Val 5
tor’)
loler and eilelar 5
rohere, Wredate between 21
B) Display do-b emp Who ove not Cheatet
mysq) > selechttiom emp
phene. we Z2> Tecery 5
ov)
yohene ee not in (CLERK )5
\u) Display dot ange Who aye not geting
Commitor)
mycapl > celect From emp
whee Comm Fe null §useg vi iil Cord Characlene
Uv
‘ ‘oO rand all chara
°fo (pee ile ) rec
LPI Miplay the eto fable emp Whore Nong
begin with Letler ‘U i
Mya S colect A ~Crom ea?
‘gh. where ename like ' Volo -
Display the do. ‘ emp (a name we ley
‘Vv!
| mysgl > select fron emp
ia where enarme NKe “kD
| 9 Pipay tthe dio. emp whose. names Conta’ n-ty
mgd» seleel from emp
Where ename UKE ‘ete Ue! ;
4) Display the Aso. L emp Whace names Contain
the leten’’u” at 90 postion
mysgyd > delect& from emp
~ where erame like ‘Luge’;
Eorling he the dele | \n the able ¢
© hort —the dot emp ‘by sthety depec nek
mysq! > select from emp
Orden by deptno;
@ Sort the dot emt by Thebve Jobe
q) Sseleck Krom emP |
anvies by job: i
mysey
3) Sort ~the dot emp by ctheiy. Salaniess 19
decending ovder :
mysql> celect € Crom emp
onder by sah dec;
A) Sovl -the dat emp by hei siting dale
in devensny ovden
mydq > Select & rom emp”
oxden by Wyedate desc}
9) Sovt ~the dat emp by thew depasrdmen tx in
asending order 4 Satosites decending order
mys I> colect &Lrom em? 1
order by deptno, tala dec;
Noles Refautt owt orden is atending
—
Gnteowie WW Questions
fHow cg ces desc!
‘yere to dleccribe the fable
Ab a Command
definrhon
3 Asa option ‘hece’to. cowl {he -lable ‘dela
in desce nding order «
#® create a table le
-thad rnay cons}ets 7
YB average
mys) 2 create
snoint vefene nce
Moankl | int,
™. \ :
eS aks > int). ,. pd tb quvenc@cadiia 5
gtove ~the actudents mail
d, Bsub marks, lot
-tabk slude moovks
co Slud- info Céno),Releiog primes ey 2 AROWP A
Ip the chable +
> create fable vail ¢ |
tooth no Int not null,
Coaehno ie null,
coin ng int not nally
Primayy key Chesrthno, Coach ne,-traIn ny)
movethan one “eke ‘
my sot
J
mysql dinsenk Indo ail values C1;'st) €65U) 5
kexthro Coachto ~lyain.no
1 8) 465y
2 SI +65U
' {
5 \ ‘ 4
2 $) 465U
: S> bby
2 G (Sy
) Ad Sto 4654
' S 4655,
‘ 1
Note s- all—the 3 Column nvaluer. Contd be duphiea
He In x Single Indance. u
wthis ~ly pet of primenly lel fon save Kraul”
AS Complet Primooy key. ~the paienanyy Mf
Gesell 8. Known as ~the Composite prim
Key OW) candidate key4
POpEAUIT Ceoeliaing St uced “le SO
o. default value in -lo a Calumn |
nyse ec ee le ye
Cno WE wot nal)
Psimary Ke (cno),
Cprame Voc har Cth) not null,
rrate decinnd (3,2) not null,
unite decimal (6,0) not null)
arround decimal Ca 2) default Boo
5 Pale {
nysg! vingert ito bill Conoicncmne veute )
aluet Ct, ‘owt! (25)5
Relating the lables S= two or more -tablee
ave slated loge! hen lo ertowce the oeles
-enliod entigni-ty bl cata Hem of thote
4wo slated —tablec ,
onGx 6) gladelele Studs
Sno
tray ke A
rake 9
manks 3
lote ee A Common Column binds -Luse -lab},
wrth srelortionship Cond Lion
‘ypes of of srekrllonship % Ps te _ vail
ee cro Pno (PK
“one --bo~ ran
“y Many ~ to - one .
> Many 4a — mony oo DK)
Pro
a)
Pro
fee? eno :
Pro wt
Toining “he “able “able g & joins ave used +o group
Wider
daela Hlogethen rom one ov move ables.
vorthoul ~the foin condttion, lhe *Jaloles “ave
grouped ~fogether roth Cartesian product
Fey all the yous of one fe. table aw ave mubliple
wth all the vous “ol other table.
we can Celecl dala fran enulliple dbl
cpecilying Mo% than one table Inthe FROM
|
|
|
|; Clause 4
and Uting WLM CAE Clouse Lo specif
che 301 Cond
ihe lable. Mon, o« aationthip, baey
The Cond i-tion used
Gd In pliers Ck
sep a matlen delaile Cov nerd chi
selationship bly ~the suo lables the most
commen Way IN which fables’ Can be jeine.
“the srelationship Condition cowes-the dala
lo be tightly bound with One —4o-mony
oretafionchipe .
Types of 3 ationchip 5
+ one —-to- one
one ~ to ~ many
many tO- ‘one
> many] —to —mony
she tables Can be gine) Yn one oF ~the
fatowing enethods :
$Jnnex fein Cov Sinpte- Sot
+ owler Jor)
DLqui Foi & Sn IH rrelhad —the ~labls ore
Joined together ucing ‘equals fo! “operator
cl the gan Condition . i4 alto
Known oat Senner gan”v] '
yes select From emp, dept where emp
deping= dept depino’,
oer eng only celecled colurnns ~from a
a Poy Selectgedronp emp.empno, eMp-Rnarne
_ OMP.Fob,emp. cal, dept-dname, dept. loc-Lrorm,
emp, dept
where emp. deptng =depl. deplno 3
3s Uta ~larle “aliasier"Cduplicate. narves)
nyigh > Select @.empno, @-enarne, @ fob,e, sd,
Adname, doe ror empe, dept d
) ‘where e-deping = dep Adept no}
|? Alernetely 1 we Con aleo use -the "PAMER Toth
for the Same sesuld.
iy caf dselect e-empno, e-ename, e-Job, 0 al, dann
d-Joe from emp e ‘nner goin dept d
on e- deptne = 4A. deptno:
M4SqLy celeck cy. SMO, S4-sname, §2. ras 1,
S2- mankss, G2. imesh
from studuinfe SL innes Soin Hea engl $e
On SL&M6 = Qo. Snos
afr ont THE Lyths method ~the tables
een ~thelr ave not toound by aelationship
condelion will be foined Jogether,
Be mysql > Select S1-8n6,§1. name, s>-marksl
Sa. manksr, GoemaxkS3 oh 1 ie
fromm Sludsmfo cl sett Guten Join of
stud— marks So
On STSng= S2.Sno;
Nolet OH Lek att mous of Mable” soHth
molehing yous of other table — _pvyned
af the rrodching your axe nol Aieploy
at port dlisploy the null voluee >:
Bell Tak An—this method -a ~teble Re
caine Heth Lo disinguish the, bo
Aiflesert vestiane of the Same lable
we uce —lable alvatis (duplicate)
= myeq!y select cempe, rae eit
mempne, mere mfeb, maa:
from emp @ tell outer Yon. emp
‘on emg =m.emp N03
Lunelions 2. A 4% ean ve Salined at cel
V
Conlained block of clatemer “hal, Peg
, Qn toat ete |
as bolh are ued ~fo perfown “eth they
Alen a the way -f ean Occepl He
Pararre-lexc and -wrelurn Value bated Of thy
Purpose of del\edf
® Mothemaliea) pt
® Sy! fr
® Nore ae
® Aggregeele cn (ox) Group ee =
fr gelurn a Linde sretult you) Valug
toy a group of queda) vow of a al
group oY
Doount t= Gelumne the novel rows in atebl
opHonalty no of Valuer va specified Colum
£4 mucql scelect count be) From emp
dees Count iy
ey Mmycq ls celeet count (comm )Lyorn emp,
OP! Count 4 os ot alors
Eg Se mys > selec count (itlincl yok ')fiom enps
olf Count 5
WSUM = Stelusny the Sum of all Values 7)
oO Column
Gee myst ycelected sumlcal) from emp,
‘sum (cat)
it Average & Fehvmn the all cuenage volue
PA he CRAliumn aet mysqI > Se lect tg (tal \ heen emp;
ovg CAL) a.
WV) MING Setuwnt the loweel vatue In the
\ Column
exe mygd Sctelect min(cal)trom emp,
) mysg I > Lelect min(hivedate)-From emp 5
v) MAX Sx getuvns the highect value In he
Coburn
us i) mysqd > elect mar.(sal from emp 5
9 mycgd sscetect. mar (Hwedale) from &™P ';Cin
U Kael ree By Clause +: UF ueed fo
sretuen ~4 ~the agpegate Ciummary) bowed ”°
A Cale garry
Get mycg dx Select deplno , count) ror
ae AUP 4 “pire
= DEPTNO COUNTCE),
30 ‘
iS
26
19 16 3
ee my cod > Select Fob, Counters emp
group by Sob;
a
= JoR Covunte) Managert “
A
Analy
ClERK
Salesman *
amoel LeX83 mysql> Select deplrio, Seam Ca) ron emp
qvour oy dep no,
at Depo = kum (oe)
30 C1LUd9
20 loetS
10 VI50
Usoy Having Clawe sO i uted to tle
the dela stelurnd by using qvoup by Clay
re mya) > Select deptno, cumsal)) Crom emp
cok by deplno having sum (tal ) Z (0009
Me Deptlo Comésa)’)
30 AU06
wt ‘© g450 :
Whosoce bus wuere Sven Clowes
“the hese Clause Can be uted in any “type
of select sah yen rohene. cut the havin
Chose will pe used will be used onl
with qrouP by Claue.
SOUMNDExCD % WH will selen the clorta foi
nthe sable based on Pronounc ice! top Chemo
/ at the ‘value in the -fabk -le-the value)
we have Specitied @n the qelery -
iLAL my84) > select st rom emp Where eames Gl
AP no Youn Seleoted
2) musals celect a fom emp Whore
Soundex Ce name) = Soundedtt lov")
OP
Emprb Crome Sol May Wivedale Se) Comm deh
AYgD Clenk mq “iR3q oq Sune! 2usy mall” 16
Lub queries = Sob query ary poy that Fe
debined to another query Generally Lubguexies
are USE to sielive data vom Gre. fable
by using “Ahe data from’ another query.
3 “Te trelude a Subguerg ta Sevect slolentt
Simply enctoce —the ‘eubquery Pa Paserrthesces.
the Inneamect quey pill be executed free ne)
He cutemoet fact.
oS Lubqueries ave an extemely powerfull
—eluve of Sql- Subquerter ray he use
Wwhesteever exprestions ave allowed,
—Eeampler >
@ Display ~the employees, who ae having the
at of emrth
Same profile
muycaly Select from emp here Job ~
(celeck fob-fOM EMP whexe ename> smith!)-@) Display-the employees , Who awe working
Chicago.
4
mysql> Select & from emp Where deplre:
Ceelect deptno rom dep} Where \oc=' Chicago
© Quplay the employees, who | gethog the
lowest Salary, ‘ji
mycql s Select & Crom emp ae gal \ >
Coelect minlea)) from emp) s
+) Dirplay the employee, ish folned taal.
myty d sceleck k from emp where hvedate
Csclect max Chivedele) rom em?)