Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Date

Page

BASIESOF SOL DE

sOV6ands foY shrucHured Qvey Languaje


u
what is Sau
8oL a standard langoje Por Acessin
and manupladin database.
99Lstands For ahvcurcd Quay languae

Basics dot
A Colobase most Ofen Oontains one O
m r e a b leg. ach able identiey name
(e Customer, stUden+) b

4able ontain e coods (oows) win dada

SQL Cte8tademen

CREATE TABLE table-ame


Columnt dadartype,
column2 dadatyPe,
Column3 datatyee,
7. Y

noTe69L iS not a Case SensitHve lnguaje


Date
Page

S0L Select Sladement


.Select 6tatement used Hoe eet daJa Pvom
dadabase
in desul4 table.
dada dcned is 1oned
Called tne desult Set

ne Pollowin 89L 6tatemen+ Selcats the


tm OusHomer
CustomerName' 'ity' column
table
Seleet Custones Name 5 city foom Customes;|
Ddotb lgono
uexample barurle

6 tLECT FROm cystonneYS;


>SeleS all Columo Poom CusmeY oble
102Tafnc 9 0 on
,

SoL WHERE ClaUSe n90o mot0)

b /hjeTre wHE RE clauseo&0sed to Cite


oeCDrds
1 4 is USed o rexiraotonlythose
decosds nat PutlPued a 6peiPied
Condion do JJA TA9

SyniaxK C uloO
SELECT Columnf, Colum)2,
FRom table-name
wHERE Condition
Date
Page

Comment
39L Comment3 ae usedtoGdd
Dote +o oUT CO0de

examplc a
This s a comment.

Oule),m90
LoGical OfeTaioxS t . / 7

AnOD opeato
The AnD operador disploys aecord
Patluthe Gonditions emeted by AnD
OeTRUE'O ron 5U
AND 64ntox:

Selet columnl. Column2


foom table-name
whene CanditionbAnD Condition 2

OR operador
n e oP Operadon disploy a ecoTd 1any
ortne coldition 8eprated by OR S TRuE

OR 84ntax

Selet Columni, Column2


FRg M table-name
wHERE Condition oR Condihon22,.
Date
Page

nO7 Opesatox .
3

tne Opetator displays a decosd


O
e n e Condition(s) is NOT TRUE moN

S4ntay
SELECT columnf, Column 2..
PRom Hable-name
WHERE emdiry!, NOT Con diton

example
d

3 seLECT FRoM Customes


wHEPE NOT Countyi41y';

4TN Ope vaHO u l e ) , lomuleble

ne OpenadoYallo Houto SPeaiey


multiple Nalue n a wHERE clause
1He T peTatoY 1S O 6hovthand fo
muliple 2 Qondition

Syntax
SeLecT column-nameS)
Ro able-ngme
whERE Colum-name w
(volve',^Nalue2). . .

U-3dot
Date
Page

SSaL between ope daJO%

TheBETW6ENOperator Selea Value


witnin O iven ange tne numben Can be
+ey+ oY dade
he BETWEEn operator is indusive
beain and end value ade includcd

6undax:
6ELECT Column-ngmes)
FRoM able-name
wHERE Columo-name BETwEeN Vave Anp
Valve2
6 LTKE Opeado

The LTKE operaor is USed in a wHE RE


clause to Seanch Pos O Speieied patten q
Columy

h e r e Gve two wild Cads oten Used in a

Conunchon i t n ne LTKE Operato


h e pecent
.

Si9nCi.) aepreJent 2ezo


one, o multiple chaneter.
Tne under SCo Si9n(- PepreJent one
Single choncier.

SunHay SELECT Column, column 2


fRoM able name
WHERE Col Umn. LTkE Pattern
Date
Page.

SOL JOTNS
brou)i
he SoLDJoin calusse Hake TECOsd S
Foom twomOd more tables in a databasSe
and combines togtnes.
TG 26r n
Arnsti Standod S0L define S TyP of Joins

inne3 Joìn
2ef+ outes Join

3 ignOUtennJoin
Pufutl oute Join
SC00SS Jointn Totnr

i n n e s Join

table +able 2

=inne Join

The TnnEe Joinkegword Sele Tecords


that have matching value in botn ables.

64ntaX: SELEC7 Column- name(s) D


FeoM+ablel
+able2I:
on able Column-name -
table2
col umn-ngme;
Date.
Page

2) LETT JOin

Hhe let+ Join Keywovd beuon all


eCordS rom nelept 4able CHable 1) . and
h e Matching ECOTdS Iom e ignt
able Gable).on'ok
+he eSult is recoOsdS foom
i9nt elde. iCnene iS no match
tne
tne

Sytax
6ELECT Columnname (e)
FRom table U
LEETJOIN ahle 2
ON TABLE1 Column-name 4able2. »lumo
name
.

able able

etJain 3/12

3RIGH1 JOIN a.

Che Rignt Join


keyuJOTd detuans Cal
mecoTdS
TEcordS room ignt toble tobie2)
,and tne
matchin TECords Proom the
table )
eP4able
n e oesUt IS o becoTdS Poom
+he lePt Side itner s no motch.
Date
Page

table Hobie-20

Risht Join

8imax

SELECT ColumnL Mame s)


FRoMo4abler
RIGHTV JoinJuHable2
oN table. Column-name 24able Column-

name;

2 FULL JOTN

Tne fULL OUTER JOTN keywodd detvans


Oll TecordS When nere iS a m a t c h in left
C+abe) 0 i9ht CHable 2) table ecovds.

noie pull oUHer Join and tuu Juin ane Samc


Date.
Page

oble Sable

Pull Join

CUmoUS- PooJammes.
6untaX.
column-namc(s)
SELECT
PRoM able
PULL OUTER JonN table2
onN tebel column-namc +able2 column-i
D
name
wHERE Condion;

You might also like