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

SQL pdf

Uploaded by

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

SQL pdf

Uploaded by

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

= +

Lechune 4: Zahoedcin to 34 L yd |
¢ PAL won den ‘hee Th fndian nelatto ma

a amd 7 i a Wie sided (Tek). Bud 4 vo radon]

wie leuluy.
+ Im) a. Fils neler ions Twos SEQUEL (shuctumed. wired ae

poge)amd laden it vmo. manned ao s@L leu

roe odobore emo de) to pecaue 4 4

Wwe cam ever Jah luple pec duns

Here, ,tavle to nelaHom, now %o

==:

we <n ge hia like trod 7

AY zaTron —
CREATE ScHenA aS aw AUT HORT Drove at
Ee

jectuse 2 Coeating 0 Table and tont cowlnageds omit.


| @REATE “TABLE EMPLOYEE

‘dou alts he we “dw! of

( WAME VARCHARCL5) Nov NeLLy a a vols


oy CH} (1) Not NUL ‘Gs wml Se (locple to br
NULL.

Bdate Bate dats, ‘Bnd Y coe econ t Jo opecildt


Supers CHARLT) + Zay, Prod 20mme ott

AXbald nat be NOLL pace Hol


eC

PRIMIARK. KEY (¢S) See ed ee corel tole,

FORETON Key ( Soper ss) REF ER encts* 61H Vs comenttion Nat ee

EMPLOYEE (s5n) “we wnite We Sql Yon cog

4+sKETE IR mot 1 Oule . s/'We


ioe Gunite ++ + 1n S wrcalt leer

| «by Default+ prinrray Fey NOT NULL.

‘i kes NLL.
= sa 7 ; e at hip he Cam mere)

4 Un cove. ae ain Medi pace fom Parahena,,


a 60 .
Sead comet ayn) Fe after ee Mere i Name of He Fonte 7 “t

.:> Pa
uid en

Namme cPaEMaAny key) VARCHAR) NO re

RY KE
Nome VWARC sina te Not Nvle PRIMARY 4 7

on
| Name VARCHARCIS) TOT NOLL
) ORIMARY KEY (Neve)

*I4 we nega am at bubute as pele of com


Fable voltety we one satin ind exten Hae dodebase tian |

Proll ave euon,


Pate

; aie \ ‘ryt
—_ rail “oe oe ce
& 1"
e ry nec} ae and aan MNWrnbeh
ae tel ten
CHAR(m) - ned chamoten o
VARCHARCH) - ee Ve mk dronacttn, ray nave ang hing

; » m 0 to”,
hh

ums FIOT REAL

a tl

\ | Nt Be croracten
poe COM Cuan COMCA

| ening, wing | “in,


“CGS Ob ag? ~obee
! i r abou.
SITS In beg!

Tf 9 Nave BIT(h) wea ah re) have fixed lemgth BIT gene

mwem dove “OI BI 1s adh “q gules

cam!

Boolean Soa be TRUE FALSE


B TWwe Cam Nave DATE-00- DedatFype, We Cam evan cneole a Garment
6 PLeer.ow ownlke phot

BIT VARYTNG( ND

Ee

Connlacdnls
Default combacdnt! 4A. ¢ d

$e Dia BAL Te. PW Pay ale ©. |<

a awe a ae =

nae TABLE Ef IpLoy £5


Nor NULL PRIMART KEY,

aes
og Nor NULL + Zz
is pe NOT NULL,

e chant 2) DE FAULT = cg
on declmre )
4 A ccoading +o ow ve comand, “f mo val We vai provided

i PNA of EF CMMs eT
e_compad ble set os

caltton to whietn' le
A DroestHion of NULL (a> default val uc) I> por ble yi,
ammo

co] umn de. taitio" Dea Eda NOT NUE 26 wm

Vanve NULL a> de aul E


ak Column com} YOAV. a ome fault value .

we

check rawlnoidt!
at Orns + valuer trot cam be \noentd bre inte A

wt a taile. Fon Rm eo

eee —_—

TABLE em
PE ou PRINIARY \SE%

( ec ode ‘yet N I
Cmowre dso) NOT NULL

Ser Chanld) NOT a onal,


© chon( a) DERMAL

om decime) CHECK ( from > a0): | |


Thko lodem en} Ores thd The Vale ve) FeO fo, ner

emnust be preatees Won 2000:

Th Comba

CREATE
Mahen a check com toatl pee a te om Stine
ec} ed] a’ fn oll] Heo caltiwans Nowe “ie

the sore table» | p BY opes ifted ad

pal Fon imbomces

CREATE TABLE hems


( P code chanl (4 NOT NULL PRIMARY KEY

deep — chon(20). NOT NOLL,


ROL = }mt

QOH when
CHECK (ROL QoH)

Fi piece et tus colt wwe ROL omd QOH, Hous,~Hhen.


| Y00 a muy be defined ia tno check Corto

ae "i Laie Thane’ The came value

Ga tia coecl to ‘opp wv

Np govwwlncu

4 Fi”
teem declaned N

: gy NOLL:

+ cond ant
et NI6,UE cowrount mere oe |
We. ewoueo “Prot me atin ai the Ose ©

e
vit an shoum be low:

CREATE TABLE enmploge |


C ecode 4m NOT NULL ONTOUE,
(20) NoTNOLL,

emame ¢
atx alt) «= NOT NOLL,
: fio
on dectrral )*
om comaltion Violated thin

"enous ant of those Compl


| ne ee ca whan ohuylen He di ee |
pany

vigted ori aol om Foon com . be


eat ee al teniggened ed action

the iret ‘i Tel ne con ape!

puch £0 mame :

\t fi Spec nes |
| oe i sell me fo iz od soled. sth |
alno cal! 4,72) pes GT. option + . |

[
a a eae eis
eee Davo a
: ‘ ——

FOREIGN KEY LDNO) REFERENCES DEPARTMENT Come)

|’ | efownlil aipgpine action! — elicell than Hrooe achow 4


| Geet NULL, CASCADE, SET DE PAUITS © “on delede off on upadhhe -
x
b ;

SON DELETE , On UPDATE 4

: them th e
I. om updite et NULL achion tp nrnade
RL ie "ie a a be ‘rode NULL and om Caocade

whodeven AcHon \o px se acai \+ wl IT pao ne


tote ne ffenl > i ii ree

ns Bialefed es ep

tet le ‘Ne on Ww]

the me he ye ee i - Ha ~he dell iste all eit,


Gin Me able.

* rave eok 1 e tobk) Lg i445 fo)


Lippi a entities vale po og

sn] ! } Ess)
|

ai 14 1 0. sabdinhip fable) thon oe mage LY gral nage

to op cancade T+

i ay emdo rool iS all hy pee tiles ve

an 60
ehien % ve Je dosn otha, Sie Fim seis ill L,
Sylar! eysAt=p C4

F@RE IGw KEY (DNo) REFERENCES oe PARTMENT Le ON DELETE


GT DE FAULTON UPDATE CASCAPE,
o ~bLone- SE LEC cy rROM JAWERE Sys,
Te do nelmtleve On uboet of mawn On Cal bm in,

i coe Be ee et
v) ne 9M eye Vea
hon . “™m, SELECT 1 terlerment! \o onl Py

“Im ‘Wp c sim pleot


aELECT <¢olumn Vane? [ ¢olumn cane

FROM lable rawme>’ of He


a we WoOrt to view only m Cowie, |
niieegichy

FROM em
p coltum on bh),
aie cate orig coho he ie
10 o compl
bang ried nol ed ba compted Vt ot rohan ofall tN,
SEeceer’*t i!
Bow! denne ha ole? edo he

t The ovden 4 lect 10” 4 vos

* cee P doe fall ne

all the doda a he S€nls


Nown oft {see od shell

wre Sas rancr Ke


, of a GLECT aire

she agulty
exh SELECT DISTINCT

Ne Step toble ma ; Roeser


but the 5 at of the_queng ah hould

bel 0 peer al]


eo dae } ane?
ame NOLL value Vy edu ned

+ whunever ees sia


“in The on egul: ” mo “nattes ho co(/rmom NOLL veleo ard

e1coum
4 DISTINCT ™ inl apple to the emP ine ope you, WHO

Hic
pene Fe ee
The IWNERE Clause 1” SE LECT shalementopenifi ae |
Cal ie n vel lechem o| nows fe le Je funn ek. |
SE LECT column Mose] 20 of tumn tae rawer, -~ ]

FROM <teble mame


LAIHERE <comll Homa, q
| com combo the SELECT im SAL 2 par pa ve selattonel
Sis ,
lene , one +20 Jp) of cand Hom:
Comh Hom

otm Conch Lion

cele om

if

&.
ss
Lwhemenet we dake ane table amd ; nbtcular addasbude,

wre

hom ib As ealhed oe lecHom comci Hon, And we tke ONL uy |


jem lifferen deaple Yon Comdlt-jow them bh « «1} eal ov olny me |

er! O Relay the name, odd al am employe hone S6N2]¢,

{
Select SELECT Name,odd FROM Employee WHERE 4
ew =
"all enns.ol MPPG*) <1 elation
DvPlicade elim) nation mot happen be c cure

\) eee ver cont


\liveny dem wll dom taut to ebdmdvrate td rode means wrth Vn

gr we reed deaplicade value. aloo ¥en ona

unchion,

The output a. he pelect quas \o mp ho set. TH Yo a ral 4 sed |

ama oet we low drplic but w anal He toe allow cag

(£2 Retrieve the nome amd addnen of all omploret who von
*§ 4 deport” |
eeane dpa |

> SELECT Frome;LrameAddnens FROM EMPLOYEE, DERARTMIENT |

IAHERE Dmrome =*Rereanch’ AND Druweber =Deno )


le —

. i a0 a
roy) frag 4 with a COWdsant fave] wrth bho leble otk battauys me

He Bact A Lert mame oh Wats vetweckiode pugavtoan

Prablennn We une d .

OAS medal
=o Dep

Fos Cag enmployer, ve lieve The employee's ost \asherane ol

In onde 40 get trio we wll we emolo eg teble —


CBGL allowo 4a differnt table drawing dome ohtshube mous. |

i]
i

| |
“To Ime do} Roh ll tio, deat t.00 odbu bud bolo
Some noume Yr we tuble tox cam Walte Uke Hatred

Emp DNO b Dep. Dno

he PAY, VSN wlth Ss scumach 4, wi t| Hot hoe pro


wom se of ES dalle adh fe oY Dep table -
But aman of the Hime the table Name th mot smal). OH, toe §

~ mead to watte seg Hat name of “he table pefone the athe
lek e mane Same . (Ro, Loe ane Undy :

Mare wwe \ “
altar acon woe one a “bable Loith Aome NONE ayn tna) |
will he dome tin FROM clame
| Bs! SELECT E. Pram, Lanne, S:Frowme, S Lame, |
FROM EMPpLoyEt As & EMPLOYEE AS 5

WHERE Es 85 air’
_— " - dom dove vat

we cam em woe the ahha


© hud i met me cen sah kena jaan mone

SELECT E- , cE. Lrmame


FROM EMPLOYEE AS E
JWHERE E-DNO=‘10))

\ om \ om |
E Lecluneé: Duplicale tagheo amd se open iLaive dupbles

’ SQL waa ecoad ie. tye ae ar Mul get} Hod “(|


4 Values , T+ dor} tre cd tap oo sel EMPLOYEE IA HERE

cat CELECT prsTant® Flame


=4 ;
= Raph we com wae tne Witke
]

i doh
In cove | we dor rk wai
ALL on ve! unite DISTINT Ke pow

len on well. ha?


duplicate mP aul came FROM EMPLOYEE J Where DNS T |
- ete e& WHERE DNOS "4

SELECT Frome nee Weaghe —rapeee to! | beclh!


"In set openarion Y de |

— ~e 7

8 aon? |
| Re ace
| Loe ann A agi. wey! to EXCEPT | 3 14
f 2] 4

TNTERSECT (Inteme ct on) e |7e

i 9 Gelect all the Frame o 04 Emplogern ine or eg hey


4
ie % n on 4 a Urlom. —_ (Ome m. we com aloo dor’ t wnt Je
(—— Cast inct be Came On fom
( SELECT PTSTINCT PAAME FROW "elapll ale "ff he

EmMpLoyEE JAIWERE png" a


(Sercer DISTINCT FNAME, FROM EMPLOY EE WHER

= “aq ) a

4
Be} Aomet4 meno en rane her ERcEPT f INTE REC i, a
i dow voter to dearwnnve —— e them we CaM Une UNTON ,
EXCEPT & TNTERSECT send an UNTON ALL, Ba cep

ALL JINTERS ECT ALL pectivel In tho 1 woe wf

‘Kall dis slicade m Hen thet set sfondi qe

& And pe rome oven Wwe. ll apPi Union om Pb om tepleo my) |


| umlon compat le fees, he all teplen anould Showe SCWHC

clotvber & p all Te Jaloler a-lyave some domaln fox Ye

chocgodhg _ In come of
é or S ate of ILS
' R R Unions R UNDONA

QO)

OPP
RP 2
>

t 'ane- Ib to ued bs Btytin congo a.

Hane wedhave two menatos f Ald

B\Y “ *, wale epg MUM EH d XN OM mane


f chon OO fey.

WW umndlyocone ) ~ Thsepaeremt to ured to seplace om e Je chores


‘a ct al the compen udnase Frome contain Nov! onan |

SELECT &f ;
Prom EMP WHERE FName LIKE “*% Rowi aa ti |

9 FName Lake “-_V% Lett M2aM « |


Hind Vana. ote of BENume onuit he V.

Now Al want % on — Im companloom dan raf toe Woe Eccope


| api hy mallee FName LIKE cea gee Freon
iy acttn wut be s hem om cpon ‘
i saci AN tab nad a e ) ) 4 Wwe Yat These
ide HY re av nee “fram Lorene besa

f atutatennt* o oe wo (" 4.
| i" adoime Loe Com Oven peypsr Com c ation (1! ant
| 7 examyl ss ywamt to comeadhemadte ered route ant
“thon we ¢ ae Nhe Halpe te GELECT’FNAMEJILNAME
thom we cam neo thot boty one concamate 1
‘ —_ —
(Ne com ener "
w do 4 L~, 4 / on MUmen'c dormadn Alt ’
i CELECY #FNowme, @ midelann ashy)
| FROM EMPLOVEE | ‘
| Be :
| TIWEENS “Tht com be done Im companion

fon trample}
ELECT * FROM EMPLOYEE WHERE (SALA
odo0 AND 20000),

RY BETWEEN |

between mean: lO000< ¢ Salon £ 20000 ,


| % Be-bacom Yo ac Yonclus ve mn tne \o alan
: YWicluoled,
Le clue oe On den by
i pia ie em £0 amd No ech One wo
ot uartogn Each Jepnd ed,
, nee ‘i nak samme, “then wt tot Mame.
ondincordleg ¢

‘ Fol! ooden NT ott ascend


4 L so O09 sy |

We hove ORDER ey yor am §


Yin the seat we

te attributes a
OR DER By clame eet rl on hom the atubute
— OPPRON im the st ap oni
>CELECT D-Dnamey, e-Emome » Emanrt; Ps Priore |
PROJECT P. DEPARTMENT D

FROM EMPLOYEE & E NoRKON


dov't wate AS then al? ‘Lb comed: |

W 4ie \o a alien . te
HERE D. Dmumbtn = &:Dn0 E tone latssm ANP Pang =P.

Prusn)

! GRDER BY D-Drame, E -Lnamme, Es Frome ,


— tBy dedoult onden b ondey en wi im anced ondlty
The Kee 7000 fon anc gvdise and dL ane |
An DEGC. j
me
a SUUEET ccabuman mona L dcolvomn mame _

FROM chable ramme


Lintere Spredicote)]

FORDER BY <cclunm eave] J Asc /DESC:

ev ()RDER BY Deora pesc, Es Lame Asc, ©


ORDER BY Ds brane 7

Ty ogg Poy aes od be resent


dn d vohadeven poroent \m SELECT 7 uneool mat he pa
%) Pre)
Lh

in ARDER BY clame+ Anal lw an


aba e quemee of ad bibude Wwe oll Ow
Im sanne AeVENCE .

Leatane 9: Example on on Onrdesr By


7 ELECT A,B, ¢ FRO

c lawe onoden-ey
its Ordon do,

ti R ORDER BY ADESG

A BC Ome eo ¢
4 2 3 9 4 3 [rHem, duplicate val,
4 2 4. 3, 5 y one pom ib ble.
4 7 Aa 4
“44 2 1?
2 4 2 A
3 54 1 #2?
% 4 3
Seleot Apc FROM R order BY A,B C!
A Bec
, 2 A
\ 2 3
2 1 4
2 1 3
3 4 3
53°45 y
‘ A Desc, BC pese

3 4 43
| 3 5 oy
| : 3
i 1 2 :
124
Leclune 4or INSERT? | |
wares (RAW “RAVULA’, 4) 234", va), |

TNcERT INTo EMPLOYEE


ge tow 11!

7T4 we w\ late. ony vedo le cowrtowt a hie ge“

Ce place. he
We cam aloo ast onl Pane aduich we Loowt to Yet Gn wom Ve
| end INTE EM pLoyZE (en LN JW Eh) VALUES ('RAVIMRAVY LA), |

“Lol, “\234) !
HH af to athubde amd Me: 04 of otbaibudter ern |
is fs are us adn Core whe We did’ + ]

| Brune N \ eb
adhe the are ob adlbuden Je Her nusnbt wis

Ahauld exaetly be Same ann’ ib need hy be.


Gh provides Hnat 17

is outcome af if
A oqul hee “eh [i gnv4 we oo”

a 1+ leaye it rine: |
hn

e
Hie alte a ome me ‘he ath and FAULT Com hot
&% NOLL,
And ame anther vor

H all
| feta ren pat Wont

Be tel) be Yod-does 10 5 “Sill ie en

| To delale re enitine teble WR Ue

UPDATE
| UPDATE EMPLOYEE = saan: solong +] OSHERE DNO-S
ing volute ia |

to oneate Q-table In zou com waite ag


1 ap teble™ a,

Qmd the output of art can {tone I+

£7! CReaTE TABLE R( |


A VARCHARUS), |
DB VARCHAR(IS), th anceann Chas spre clalom te decline

C pecs fe upto 4.

Awe CaM Sadowel wourt™ Joris dobe the

FROM EMP?
eerect C7 Dy F |
Tneert INTO (Ay ei abiihabe thal ont det dmned In
ro at {a bute 9m Vy

iene, vee the dormaim Jerre}


+Ryn coeate tebk amd He ” adore thenz wil) be Zame
of sui! t

Sept terble the should be Gosme


Comma table Tere
of Vo ued gon tee Tewmpones io
viewed

“eT Wek glow} vor


SSE tem we ace wiew 22 spr
EX- CREATE yew Brood liens AS na TE af te eel ay
ELT * FROM Them. (owe of Hee Keowt IY
WIT ERE Pat ce \ {2°

A wero Yo a (wi

bof, \woead dunived do

Leclune 44 DELETE AND UPDATE


Wwe cam delete Haples pow ~habple explécét
tr pELETE FROM EMPLoyEE WHERE F ake =‘RAVI’

Hontt con dolote 0, 4a eat


the cond)
Cfome eal lr got dededed Me ferble will BAe her,

}
le.
drop clause?

DROP TABLE EMPLOZER ,

: desm\ney whodever to ht od Lib


Lyol be. coe of, dese ay Shane wo ible Tred 0 4 anrmont® |

LL.
tT
Ei
|

T Uk Uk
aad *Imn SAL ,even NOLL % cownidered| fe be
Nor Licimck jieyUleveg NoUbae oferta
T F a Me odubde wit ‘3 0 tne |
rit = NULL thom NULL V0 com!
del OK ah ve FALSE. evo

Blind be came “| sreforemtioul Yoke


p

PELE TE CASCA
in pre ‘sali
Syolan sh Ne lele*

DE

ROP TABLE TABLENAME/


>a al Update |

poate ZTABLENAMD SET column =

Nalue *

id Caw Aceh Wed. 1+ om OM

an on Bt UPDATED CASCADE “thom “the oot) Non

LETE FROM clebkmamsy [WHERE eparedicoses]'

| yen a4 Daap +

voduso WHERE COLom)

Lectune 12+ Dealing with NOLL solute NOLL As


ny Bodeam ex onion lor dow'* Kmew Yow $0 Inrepoet the 5

pt irae §+.}o v0 | tooe

“a TL EL UK Omby valve dow whitch ve one Tue.


; T Ule af i Ay ae aes |
Ty | ad |
FIF | F si br
bk [Uk] F ] UK Uenes se o ota
(Ue ave eaten NULL a
Unkviowm( UK)
OR Wy) nine |
Tome de» ial aa
0 we OR with Tus 0
ONT Fk puedo “True woe dor’ a ae enul
Tr tT nig sHHhue, hades ¥ be Mes

F/T F yk pig Bue:

e mMue
wade ‘ude uth NY

we wd
ing © FALSS
F to wi Hn Hue Actuation 98 L by
# duced TS oxand 1s NOT eprnot0
NA] Pn
bin, Bin NULL? § Pho Ts NoT NULL
Lecd ane }3): rN act «
UIptarg, the IN Ke eons we COM apute Above a Ww HW, :
CET comer .

q mali, dd of empla why work dos dep | 294, 4 |

> SELECT Frame, Adder FROM EMPLOME WHERE Dm In

2,4, % 5),

SELECT ‘Crome Addiew EROM EMPLOYEE WHERE


y
aR DNO=4GRDNO- 3 OR DNO=5,

saint on used nthe companloon ™ he

>The isc of oveg

(-y cele met Reon ke NRO Ve,


e) Pa nate) sai ees G |
6) Find Frome ployer who uensk For at

i) Stodtond

a
SELECT Frome, Addnew FROM EMpLOYEs WINE! DNO IN

( SELECT nen ae DEPT_ LOCATIONS WHERE PLOCATION= }

ia |
wnt cai be exectce fooh |

; ase gt ere |
ohne sh | —— |

1 x
Covadaled PS vg (1) Hoe non Conlodedenso

am coe | \rw bas owp |


nk guny ar) SAR alte Fon |

Hee ae oe eal
of for ome Valuun Garett a cmp

AMoveover, IN mea nt Wood


npn Tam one ot Hibus«

er}.
FU sHene (A,B) IN (SECT

Lectone | aE ogme |
QUECT PISTINT Essn FROM WORKSON WNHERE (Png, thus) TH
(SELECT Pro, Hours FROM RISO Here Eesn > 0!)

mS EME G) my mee poe Make Qure


a “i os re) } gel (he C lure tev es

DNO= 9. |
br obs |
Tn the Nwnho7 addy beden and the , f* of —— at
F * tahoe eh LOC OW? ali m am ae a Camm bet oe _
| a noe Fr de aol (Me ck Bie (Wre alo ther), 2 (Mreotbe “

Cg do), f= (hem moe ot] to)$ 4 (lens - thes, 4) i

Male
TR, Hg cam be combine uo) th ANY, ALL, SOME, “4 ,

InN & Econ) © (=any), Thy Ha. Na equa

equal 1p ey us) lo EAP NEM Ive Power.

Same am

Dna hur eguivalen ce valle ANY whan we me Corpora


wrth 7 ot Lobute nod voltn fouble .

Blame al | vay 200 % om Salon i “the salen


all erm f levpen€

“PSE LEC T FNyame nee vinovet WHERE SALARY JALL _

| Salons FROM EMPLOYE WHERE Dro =5)!


lection Rr Nevled Connelated Quen;

ii QJRETRIEVE the Frame ech ' empbyee whe har o dopondtert ai


| the sage 4s) manie alate ‘NE bob |

| > SELECT E. Frame, FROM EMPLOYER ASE WHERE E.ss IN)

AtK Oo W orplorte.

(SELECT Escn FROM DEPENDENT ASD WHERE E.Frome=


A wali Mame AND E.SeA =p.Sex)!

be comme sna Gomme quan [.e» NOT


| WA amel tm Wwe Seen arog
| the Fn qutn Vows ial lag a
| ee al\ ae ttople Hao will Tage i

astra pce olnmnatoe te ne


our ho " a ee hve} J. thon Tae “ott vas amd 4 mil

Ae ques oan Kav he wat Hem a0 Tol,


Lecture |Y! - ExTst& amd NOT ECE amd NOT ce omeltne
ly tt

t +h 8 Wileernd quelse
EXxTst oc: H chow ane be ahi aes cbs ust! end
TRUE. And YL churn of
Yon t+ ve wEplee

Raper Ete yr ke ee

FET IL re 5
Th \s oppoo' te of EX1615,
14 the \nkewnal quasi Sedum Lomethdng, Hho
tkdsts lp FALSE oh UVF does} see ddivn ap A
Fhom NOT Ex4sTs io TROE, . of

SELECT Frame FROM EMPLOYEE AS E WHERE ExteTs Cae Lec,


* FROM DERENPENT AS D WHERE E.S6n=DESM ANH
b. sex = D-sex AND E-fmome =D. &m|_maywe)

J Reloteve the Frames of ermpbzeas who have re d-eperdeny

> SELECT Frame FROM E—pLoyvEE WHERE NOT EXIGT ¢ (


SELECT % FROM DEPENDENT WHERE S5n-Essm)!
Here we don't do ahlartma became both the Jelbte dave Jey
home flo wel] king abort adtubule mame.

Lee due Ht EXISTS exaymple 4

Q) Lact +e Fonammts of man udho hare atleaot ome d

‘ > SELECT Farge FROM EMPLOYEE WIN ERE EXISTS (GeLecT * FRom
DEPENDENT IAHERE SSn- Bbsn) AND exIsSlS (SELECT # FROM
ts, DEPARTMENT WHERE Sorn- Mga_ 2s),

i I+ % conseloted me
This 7g b Ukes ends) eran
(+ eT ——

OT Ex Ist a! f

ae

1 (LL aw) Thin ty mot Uke?

hy don yes do n) bon (124 tom)

HL fonts ton) ‘ ie b-)

i at NM gotetton)
,

=a

' j

| l aeluve It Exsasts orasepe 2° « uno wks on all the proyecto

Re tafove AE benaume od each ome |


Cont nal lea) bg Jerod ae ia Except mMm2omW) “6,8, (82-4)
> SELECT Fame _ pen Nong conelok

Brom BMPLOYES \AIHERE


Aor ErTstS (gerecT Prumbh FROM PROTECT WHERE Drums) i)

ERCEDT (SELECT Pno FROM {ORSON WHERE sone essw)


ee \o cannrelotes| nestry

oo.
|
TZ Dvwe Fy Ym Progeet them tt not man comelateal bed d Dome,
; Net in Proyted awd 4 ™ tm plage ca thom if ve c dnela she of ,

4 Now whee veo arr Jone mndepemdonh amd CO - ne lok 7 meshin


Tode perder com be execttd ire pom the oct Quay: dh
T+ cam be erecuted ance ard te cam sae’ nenult awe he 4

Coneloated quany 4 thay te be exe cod eo] rramy -Pyenre, fore,

tuple por ble fr the oubtde ore loon fey out oe quent. On}

ao oP Frowe 4 UeoX_ON\
| = *, Dn of Bw
42 x
ae 6)
20| 3
30] 4 £12
t/p!. yee
‘ {Pro ) =
i
E 2 lo
P| Lp \> z =f
BY Rovi +
Waking @,
} do(t=4t0 »)
lf : don(J=1 40%)
H ®,

Lectane Iq: JOINE a : od the


a + thy ally call
—_Noonmal got om tre atin fr pe. / anon

Font) ABN). avn en goimegwv yo


Hae Hapjer one (a opto fn the ou pt
JOIN SYNTAX

Tol on smncounpys Ynnkn Aer?


SELECT FrromeLnams, Addie FROM CE
| ON ONO=Dnumbe) WHERE Dranves ‘ Reoeanchy,

H Even bene | we ae woe Huy Torn) condition. I ve gut


bani te Bangle j Oe tanemb Hen the aon sete conoitloy
Corto «Drum etl ve oon be OY wel| © specie Im te

f) Where

NATURAL JOIN’ a

SELECT Fagme, Lvoune, Addie x _

FRom (EMPLOYEE NATURAL soIN DEPARTMENT AS pEpT ( onm

WHere PO Bla ore T

MPLOYEE JOIN OLPARTMEN,


Ene we dae demoumire the cape ment ecble IM nu ch min The ar|
Pmumben af DEPARTHIENTY Changed Jo Ono In Au « eh & a Hha
“Hus Ome o4 DE PARTYIENT aviatchon wit mo of Lin plo bE.

Em 2 amd Depasbment bast rove a commen adtabude t


And a the hav et common athibule natunal Toler can at
Hire Hae seman at bide Yo no,

Sthe orden Im whch po} atwiiel ree rbd


on ‘Ra hoipheiaaalion Ofte bB iS ss iden stern
have ade: called as optimtal ~ oe it bpick,
+k ber vo execute The g ven

"
LEFT Outen Soin & “
SE LECT E- Lrame AS Emplo eo_Name, <h com ania ase
S:Lmanme AS 9 mi a Peep!
FRom (EMPLOYEE AS E LEFT ovTeR JOIN adie

EMPLovEE AS 8’ ON F 1 Suph_ssn=s: say)

Exvem when Ue One. sppipg the duten nm alo we am) d uve


— Bome common atl Gn rot Code use Wwe eaee Vov to won) Js
NATURAL LEFT OUTER JOIN.

Lemtene 20° Aamegale Arne Hore 4 4>

We creas seen My ANA, Sivy count, Thilo Ore voto us

Je. AN the o cHon except


Feige cole Coum cities be ond Colum, Lo Ag
£*: ns: fee att Siders \ nt ee

EW [Rawal ea lany | HA heprened maom NOLL to Lamon a


_—e A 4 72 = 3 Conia eter

a; b £. A =f ,

iio f4 48 38 ‘.

q =
5 Nos Whom
6 . aie 6 = pa ( Someta ag nee toys

orive N LL)
>Beloc} Stam (sarany) /av9 (Galoog) FROM EMPLOY Et '

com Sloot) | ava{Salong)


| age,
On,
> SELECT SuM(SALARYay Total, ova salong) an avenge FROM

Emp Llovec

et ee
4e | 19
as
“ piffemnce beheeen marin suf (
AOI

FS SELECT (rman ely) vl alerg))

: a

i EMPLOY nol Jan) ; itl 4 £Nou

Bs pitteans, Fomor) mane


oo nm aleny
; gg

sane og pesto tpg ES |


From EMPLOZEE,

ygerect CouNT(#) 00 foto we ening me wmben 040 Mo

Tohemeven BB usant to i). Sed (set Couns]


One Axppaneol to we), Trotead at eben Co] Lum) Move,
ite om vg *0 ie We,

Of we cam w1 ae
© total i Sie ang Star eoudl Crow] Ae
i 6 Comtomt on mune 1 Ae oh

Yue Cam use anni arn wie on mumben, atninge


4 SkLect anantName) FROM EPIPLeyEe,
o/ps

t § { Th com
+ Bud sum k vo mot allowed ln stalng co ae Bpplics
| Ge Select SMP nove) Them ie picts

S/0}- Wo yall give CMON»


t ™ owen Ino
“Ye ote on ee: og a
{ Ovmol i rege i J m
; Q) Select Coun ( daeshind Salona) Fyiown we,

*
"i:

> ofp!
HE 3
BS elect COONT ( salog 4HA) Snow tmp yee, ae thls Cane aehon
20M “hee il es be
; !
Tis ee! we doive apjlied Leae column bud ai ot died the he
Sin we i leet cane H Sum we =U) vole ne
Com 4 cipy| <eow ooluwm rust be One calumm, 04 \\ toe eden)

Ox. gels od sale SON ( (ealory, 44) FROM EMP?

mi vill ve EMOy»,
We cow som ¢ Luao ohiffecent bedktec olwmn » urbane f0
coraline ‘yahe ane colwwmn amel Aon trove “by oxpp hy Them
é age SUM (Salas HA) FRO Bompy AL Thin \o vedlol!
yn Gund mu truanore _ -_
Bi, Gelect Nawe From Emp where cealong<ominlsalor een,

My \

Lorem 4. . The anche a noale! Loe tee y .


“Tro fe We witbn ao fof gg
Celect mame From Emm

there & lon - lee lec | eee hal (salou) F= now Emp),

Lecdane 2 24} 43 Aagrecre fume Hon 2

— oe ——

Se Select ct Sam Adohme! callovy) ) drow Bioap 7

e/Pt
“2
Ava ls “ suvnlSqlory) 2B
Cownt we
\ sre foe bret:
jamin Mo
» & Min Lemar com hee aypplted toith Qs roe
am) bag
aii Min (salon
mim ( (ot ea V4
Marx ( (Salimglo? |
MO (ola bne tr wt lad
aa value FE cadtb :
Ee oleae erg er rama te oe
on one an. Soe well cna —murrend ¢
> oe Com ve app ed wn all +he teble audhosh omagqlle ovpton one,
Column =
glean — Y— | Hat woot
| ri Bic) elec} be | TR CEE entre tebe R
From
SL asl GRoup BY A bud thon T wont 49 greHp

A Yan the aout Thome


7 Ses al Fagle ube

aaney
=

W alne \p e Ane ull


a Spe
rant assis Sw oe
a "peti Mateo ed,
ol 4 eres Prot pe o ome hag
Q | dro} nd pe ed the
(ELS
tue com een quo Hae aa, rma ne ‘thay ome ct by buch.
- (
er)

Select f
Fhom 2
Ginoup BY AB ;

peer A, Cound (*) Enom oR ew Cio up


( — % Ym ou va hor A) jt vend be coos bol ‘ele
si ale

te une
Leer rl to use Jered ool Um,

san a | ohould a eae ial preer-hr oppenn

ey " Henstie U comb


ise hect A, BY Cound (4)

F_som R.
Crnoun BY A} e T4 Yn bmcospe ct.

Gelect A, count

Fonom R /

A io calles) Seas eee = cpt teble hy the the atu bute


Tin Quang t we rae a pial ve
: Arlo Fe sigh a g
the veallbe Jno f 5 Masih poe a
. ies
Quilt >

eae
Reet 2) Select A 1B, cou (4) ore R Grnenp By A, B:

. BR | Coun
|_}2 pu
a! 2
L2[e2\4)

1 ,. 7 n garden ho Hite Hr pane KL Cam we Sometd called ab


Vor Hhing lout er iting entine tebe Into

Ce 0 Smite cHow

a Gould DieGerd dele macal) Hoe 1p ~ro tenes ctor


SFan aach department wal ntere “The dro, {Ne musmloen 04 @ J
, Sythe deparctment Amel” thols anenane ha “Y mo 4

*Gelect DNO, Coumil-4), Avér(SALARy)


F yom Sayfa

at BY Dino;

Llag, cam le peel Iv) pekot claus

F a |

Rf. met “ the 2Cle aed oulal mai


$cc "' fern Move oves wie attubude sho

the nde gldatbube om 2 NULL value. 2

dee hove NULL Jape every NULL a be


an ere Soa
ae 0 NOLL ved than thane we

ous Now
‘Ged olog vonat olonad lil es ote NULL tp
corm) dared noup b La ae all " com} dered

You might also like