contoh inner join
Post on 01-Jun-2018
267 Views
Preview:
TRANSCRIPT
-
8/9/2019 Contoh Inner Join
1/24
CONTOH INNER JOIN 1 : INNER JOIN
Syntax:
SELECT { * | fieldlist } FROM table1INNER JOIN table ON table1!field1 "#$%#%e&at#& table!field
fieldlist
T'e list #f fields t'at a&e t# be &et&ie(ed f$ t'e table!table1
T'e na$e #f t'e fi&st table f$ )'i"' inf#&$ati#n is t# be &et&ie(ed!
tableT'e na$e #f t'e se"#nd table f$ )'i"' inf#&$ati#n is t# be &et&ie(ed!
field1
T'e field f$ t'e fi&st table t'at is bein "#$%a&ed t# field f$ t'e se"#nd table!
"#$%#%e&at#&
+ "#$%a&is#n #%e&at#& s,"' as -. /. 0. et"!field
T'e field f$ t'e se"#nd table t'at is bein "#$%a&ed t# field1 f$ t'e fi&st table!
T'e INNER JOIN #%e&at#& "an be ,sed in any FROM "la,se t# "#$bine &e"#&ds f$ t)#tables!
It is. in fa"t. t'e $#st "#$$#n ty%e #f #in! T'e&e $,st be a $at"'in (al,e in a field "#$$#n t#
b#t' tables! +n INNER JOIN "ann#t be nested inside a LEFT JOIN #& RI23T JOIN!
Examples
Code:
SELECT Employee.UsernameFROM Employee INNER JOIN ProjectON Employee.EmployeeID = Project.EmployeeID!ERE Employee.C"ty = #$oston#%ND Project.ProjectName = #!ar&'or(#)
Output:
4se&na$e
Ja"5 S$it'
3e&$an +llen
Jill S)aff#&d
6#b T'#&nt#n
*+ ro'*s, a--ecte&,
-
8/9/2019 Contoh Inner Join
2/24
Explanation:
T'e %&e"edin exa$%le &et,&ns a list #f all e$%l#yees )'# li(e in 6#st#n and )'# a&e )#&5in
#n t'e 3a&d)#&5 %e"t!
N#te: 7#, "an #in any t)# n,$e&i" fields as l#n as t'ey a&e #f li5e ty%e 8s,"' as +,t#N,$be&
and L#n9! 3#)e(e&. )it' n#nn,$e&i" data. t'e fields $,st be #f t'e sa$e ty%e and "#ntain t'e
sa$e 5ind #f data. t'#,' t'ey "an 'a(e diffe&ent na$es!
Language(s): MS SL Se!"e!
Code:
SELECT Employee.Username Project.ProjectNameFROM Employee INNER JOIN ProjectON Employee.EmployeeID = Project.EmployeeID)
Output:
4se&na$e ;e"tNa$e
Ja"5 S$it' 3a&d)#&5
3e&$an +llen 3a&d)#&5
Jill S)aff#&d 3a&d)#&5
6#b T'#&nt#n 3a&d)#&5
Mi5e S#sebee 2&indst#ne
Jill S)aff#&d 2&indst#ne
E$%l#yeeI?> field #f t'e >E$%l#yee> table $at"'es t'e >E$%l#yeeI?> field #f t'e >;e"t> table
8i!e! it &et,&ns t'e na$es #f t'#se e$%l#yees )#&5in #n ea"' #f t'e %e"ts9!
Language(s): MS SL Se!"e!
Code:
SELECT Employee.Username Project.ProjectNameFROM Employee INNER JOIN ProjectON Employee.EmployeeID 01 Project.EmployeeID)
Output:
-
8/9/2019 Contoh Inner Join
3/24
4se&na$e ;e"tNa$e
Ja"5 S$it' 2&indst#ne
3e&$an +llen 2&indst#ne
6#b T'#&nt#n 2&indst#ne
Mi5e S#sebee 3a&d)#&5
-
8/9/2019 Contoh Inner Join
4/24
Output:
S#nNa$e Na$e ?,#Na$e
I 2#t 7#, 6abe S#nny 6#n# S#nny and C'e&
I 2#t 7#, 6abe C'e& S#nny and C'e& 6aby ?#n>t 2# S#nny 6#n# S#nny and C'e&
6aby ?#n>t 2# C'e& S#nny and C'e&
+ Little 6it C#,nt&y. + Little 6it R#"5 and R#ll ?#nnie Os$#nd T'e Os$#nds
+ Little 6it C#,nt&y. + Little 6it R#"5 and R#ll Ma&ie Os$#nd T'e Os$#nds
T'is C#,nt&y>s R#"5in> =yn#nna J,dd T'e J,dds
T'is C#,nt&y>s R#"5in> Na#$i J,dd T'e J,dds
L#(e Lette&s in t'e Sand ;at 6##ne ;at and S'i&ley 6##ne
*9 ro'*s, a--ecte&,
Explanation:
It is als# %#ssible t# nest state$ents as in t'is exa$%le )'i"' &et,&ns all s#ns &e"#&ded by
$,si"ians )'# a&e $e$be&s #f d,#s!
Language(s): MS SL Se!"e!
Code:
SELECT Son4s.Son4Name S"n4ers.Name D5os.D5oNameFROM Son4s S"n4ers D5os!ERE **S"n4ers.Name = D5os.Mem6er7,OR *S"n4ers.Name = D5os.Mem6er8,,%ND *Son4s.M5s"c"an = S"n4ers.Name,)
Output:
S#nNa$e Na$e ?,#Na$e
I 2#t 7#, 6abe S#nny 6#n# S#nny and C'e&
I 2#t 7#, 6abe C'e& S#nny and C'e&
6aby ?#n>t 2# S#nny 6#n# S#nny and C'e&
6aby ?#n>t 2# C'e& S#nny and C'e&
+ Little 6it C#,nt&y. + Little 6it R#"5 and R#ll ?#nnie Os$#nd T'e Os$#nds
+ Little 6it C#,nt&y. + Little 6it R#"5 and R#ll Ma&ie Os$#nd T'e Os$#nds
T'is C#,nt&y>s R#"5in> =yn#nna J,dd T'e J,dds
T'is C#,nt&y>s R#"5in> Na#$i J,dd T'e J,dds
L#(e Lette&s in t'e Sand ;at 6##ne ;at and S'i&ley 6##ne
*9 ro'*s, a--ecte&,
-
8/9/2019 Contoh Inner Join
5/24
Explanation:
+n inne& #in "an als# be a"'ie(ed by ,sin t'e =3ERE "la,se! T'is @,e&y &et,&ns t'e sa$e set
#f &e"#&ds as t'e %&e(i#,s exa$%le!
Language(s): MS SL Se!"e!
-
8/9/2019 Contoh Inner Join
6/24
CONTOH INNER JOIN # : INNER JOIN
SQL Inner Join
+s dis",ssed in t'e %&e(i#,s less#n. y#, s'#,ld ,se t'e SAL INNER JOIN )'en y#, #nly )ant
t# &et,&n &e"#&ds )'e&e t'e&e is at least #ne ) in b#t' tables t'at $at"' t'e #in "#nditi#n!
Example SQL statement
Code
Source Tables
Le$t Ta%le
Id FirstName LastName UserName
1 Fred Flinstone freddo
2 Homer Simpson homey
3 Homer Brown notsofamous
4 Oy O!ourne sa!!ath
" Homer #ain nopla$eli%e
Rig&t Ta%le
IndividualId AccessLevel
1 &dministrator
2 'ontri!utor
3 'ontri!utor
4 'ontri!utor
1( &dministrator
SELECT * FROM Individual
INNER JOIN Publisher
ON Individual.IndividualId = Publi
WHERE Individual.IndividualId =
-
8/9/2019 Contoh Inner Join
7/24
Result
IndividualId FirstName LastName UserName IndividualId AccessLevel
2 Homer Simpson homey 2 'ontri!utor
CONTO3 INNER JOIN B : J#in 8SAL9
+n SAL 'oin "la,se "#$bines &e"#&ds f$ t)# #& $#&e tables in a database! It "&eates a set t'at
"an be sa(ed as a table #& ,sed as is! + JOIN is a $eans f#& "#$binin fields f$ t)# tables by
,sin (al,es "#$$#n t# ea"'! +NSI standa&d SAL s%e"ifies f#,& ty%es #f JOIN: INNER. OUTER.
http://en.wikipedia.org/wiki/SQLhttp://en.wikipedia.org/wiki/Row_(database)http://en.wikipedia.org/wiki/Table_(database)http://en.wikipedia.org/wiki/Table_(database)http://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Field_(computer_science)http://en.wikipedia.org/wiki/Field_(computer_science)http://en.wikipedia.org/wiki/Field_(computer_science)http://en.wikipedia.org/wiki/Row_(database)http://en.wikipedia.org/wiki/Table_(database)http://en.wikipedia.org/wiki/Databasehttp://en.wikipedia.org/wiki/Field_(computer_science)http://en.wikipedia.org/wiki/SQL
-
8/9/2019 Contoh Inner Join
8/24
LEFT. and RI:!T! +s a s%e"ial "ase. a table 8base table. (ie). #& #ined table9 "an JOIN t# itself in
a self-join!
+ %&a$$e& )&ites a JOIN %&edi"ate t# identify t'e &e"#&ds f#& #inin! If t'e e(al,ated
%&edi"ate is t&,e. t'e "#$bined &e"#&d is t'en %d,"ed in t'e ex%e"ted f#&$at. a &e"#&d set #& a
te$%#&a&y table!
Sample ta!les
Relati#nal databases a&e #ften n#&$alied t# eli$inate d,%li"ati#n #f inf#&$ati#n )'en #be"ts
$ay 'a(e #net#$any &elati#ns'i%s! F#& exa$%le. a ?e%a&t$ent $ay be ass#"iated )it' $any
diffe&ent E$%l#yees! J#inin t)# tables effe"ti(ely "&eates an#t'e& table )'i"' "#$bines
inf#&$ati#n f$ b#t' tables! T'is is at s#$e ex%ense in te&$s #f t'e ti$e it ta5es t# "#$%,te t'e
#in! ='ile it is als# %#ssible t# si$%ly $aintain a den#&$alied table if s%eed is i$%#&tant.
d,%li"ate inf#&$ati#n $ay ta5e ext&a s%a"e. and add t'e ex%ense and "#$%lexity #f $aintainin
data inte&ity if data )'i"' is d,%li"ated late& "'anes!
+ll s,bse@,ent ex%lanati#ns #n #in ty%es in t'is a&ti"le $a5e ,se #f t'e f#ll#)in t)# tables!
T'e )s in t'ese tables se&(e t# ill,st&ate t'e effe"t #f diffe&ent ty%es #f #ins and #in
%&edi"ates! In t'e f#ll#)in tables t'e DepartmentID "#l,$n #f t'e Department table 8)'i"'
"an be desinated as Department.DepartmentID9 is t'e %&i$a&y 5ey. )'ile
Employee.DepartmentID is a f#&ein 5ey!
)mployee ta!le
LastName DepartmentID
*a+erty 31
Jones 33
Stein!er, 33
*o!inson 34
Smith 34
John NULL
-epartment ta!le
DepartmentID DepartmentName
31 Sales
33 )n,ineerin,
http://en.wikipedia.org/wiki/View_(database)http://en.wikipedia.org/wiki/View_(database)http://en.wikipedia.org/wiki/Branch_predicationhttp://en.wikipedia.org/wiki/Database_normalizationhttp://en.wikipedia.org/wiki/Database_normalizationhttp://en.wikipedia.org/wiki/Denormalizationhttp://en.wikipedia.org/wiki/Column_(database)http://en.wikipedia.org/wiki/Column_(database)http://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Foreign_keyhttp://en.wikipedia.org/wiki/View_(database)http://en.wikipedia.org/wiki/Branch_predicationhttp://en.wikipedia.org/wiki/Database_normalizationhttp://en.wikipedia.org/wiki/Denormalizationhttp://en.wikipedia.org/wiki/Column_(database)http://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Foreign_key
-
8/9/2019 Contoh Inner Join
9/24
34 'leri$al
3" .ar%etin,
N#te: In t'e E$%l#yee table ab#(e. t'e e$%l#yee DJ#'nD 'as n#t been assined t# any
de%a&t$ent yet! +ls#. n#te t'at n# e$%l#yees a&e assined t# t'e DMa&5etinD de%a&t$ent!
T'is is t'e SAL t# "&eate t'e af#&e$enti#ned tables!
CRE%TE T%$LE &epartment* DepartmentID INT DepartmentName ;%RC!%R*8
-
8/9/2019 Contoh Inner Join
10/24
SAL s%e"ifies t)# diffe&ent synta"ti"al )ays t# ex%&ess #ins: Dex%li"it #in n#tati#nD and
Di$%li"it #in n#tati#nD!
T'e Dex%li"it #in n#tati#nD ,ses t'e JOIN 5ey)#&d t# s%e"ify t'e table t# #in. and t'e ON
5ey)#&d t# s%e"ify t'e %&edi"ates f#& t'e #in. as in t'e f#ll#)in exa$%le:
SELECT >FROM employeeINNER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID)
T'e Di$%li"it #in n#tati#nD si$%ly lists t'e tables f#& #inin. in t'e FROM "la,se #f t'e SELECT
state$ent. ,sin "#$$as t# se%a&ate t'e$! T',s it s%e"ifies a "ss #in. and t'e !ERE "la,se
$ay a%%ly additi#nal filte&%&edi"ates 8)'i"' f,n"ti#n "#$%a&ably t# t'e #in%&edi"ates in t'e
ex%li"it n#tati#n9!
T'e f#ll#)in exa$%le is e@,i(alent t# t'e %&e(i#,s #ne. b,t t'is ti$e ,sin i$%li"it #in
n#tati#n:
SELECT >FROM employee &epartment!ERE employee.DepartmentID = &epartment.DepartmentID)
T'e @,e&ies i(en in t'e exa$%les ab#(e )ill #in t'e E$%l#yee and ?e%a&t$ent tables ,sin t'e
?e%a&t$entI? "#l,$n #f b#t' tables! ='e&e t'e ?e%a&t$entI? #f t'ese tables $at"' 8i!e! t'e
#in%&edi"ate is satisfied9. t'e @,e&y )ill "#$bine t'e LastName. DepartmentID and
DepartmentName "#l,$ns f$ t'e t)# tables int# a &es,lt )! ='e&e t'e ?e%a&t$entI? d#es
n#t $at"'. n# &es,lt ) is ene&ated!
T',s t'e &es,lt #f t'e exe",ti#n #f eit'e& #f t'e t)# @,e&ies ab#(e )ill be:
Emploee!Last
Name
Emploee!Depart
mentID
Department!Departm
entName
Department!Depart
mentID
*o!inson 34 'leri$al 34
Jones 33 )n,ineerin, 33
Smith 34 'leri$al 34
Stein!er, 33 )n,ineerin, 33
*a+erty 31 Sales 31
Note: ;&a$$e&s s'#,ld ta5e s%e"ial "a&e )'en #inin tables #n "#l,$ns t'at "an "#ntain
N4LL (al,es. sin"e N4LL )ill ne(e& $at"' any #t'e& (al,e 8n#t e(en N4LL itself9. ,nless t'e
#in "#nditi#n ex%li"itly ,ses t'e IS NULL #& IS NOT NULL %&edi"ates!
http://en.wikipedia.org/wiki/Join_(SQL)#Cross_joinhttp://en.wikipedia.org/wiki/Query_planhttp://en.wikipedia.org/wiki/Null_(SQL)http://en.wikipedia.org/wiki/Join_(SQL)#Cross_joinhttp://en.wikipedia.org/wiki/Query_planhttp://en.wikipedia.org/wiki/Null_(SQL)
-
8/9/2019 Contoh Inner Join
11/24
N#ti"e t'at t'e e$%l#yee DJ#'nD and t'e de%a&t$ent DMa&5etinD d# n#t a%%ea& in t'e @,e&y
exe",ti#n &es,lts! Neit'e& #f t'ese 'as any $at"'in &e"#&ds in t'e #t'e& &es%e"ti(e table: DJ#'nD
'as n# ass#"iated de%a&t$ent. and n# e$%l#yee 'as t'e de%a&t$ent I? B 8DMa&5etinD9!
?e%endin #n t'e desi&ed &es,lts. t'is be'a(i#& $ay be a s,btle b,. )'i"' "an be a(#ided )it'
an #,te& #in!
One "an f,&t'e& "lassify inne& #ins as e@,i#ins. as nat,&al #ins. #& as "ss#ins!
E"ui#$oin
+n eui'oin is a s%e"ifi" ty%e #f "#$%a&at#&based #in. t'at ,ses #nly e@,ality "#$%a&is#ns in
t'e #in%&edi"ate! 4sin #t'e& "#$%a&is#n #%e&at#&s 8s,"' as 09 dis@,alifies a #in as an e@,i
#in! T'e @,e&y s'#)n ab#(e 'as al&eady %(ided an exa$%le #f an e@,i#in:
SELECT >FROM employee
JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID)=e "an )&ite e@,i#in as bel#).
SELECT > FROM employee &epartment !ERE employee.DepartmentID =&epartment.DepartmentID)
If "#l,$ns in an e@,i#in 'a(e t'e sa$e na$e. SALGH %(ides an #%ti#nal s'#&t'and n#tati#n
f#& ex%&essin e@,i#ins. by )ay #f t'e USIN: "#nst&,"t1:
SELECT >FROM employeeINNER JOIN &epartment USIN: *DepartmentID,)
T'e USIN: "#nst&,"t is $#&e t'an $e&e synta"ti" s,a& . '#)e(e&. sin"e t'e &es,lt set diffe&s f$
t'e &es,lt set #f t'e (e&si#n )it' t'e ex%li"it %&edi"ate! S%e"ifi"ally. any "#l,$ns $enti#ned in
t'e USIN: list )ill a%%ea& #nly #n"e. )it' an ,n@,alified na$e. &at'e& t'an #n"e f#& ea"' table in
t'e #in! In t'e ab#(e "ase. t'e&e )ill be a sinle DepartmentID "#l,$n and n#
employee.DepartmentID #& &epartment.DepartmentID!
T'e USIN: "la,se is n#t s,%%#&ted by SAL Se&(e& and Sybase!
Natural join
+ nat,&al #in is a ty%e #f e@,i#in )'e&e t'e #in %&edi"ate a&ises i$%li"itly by "#$%a&in all
"#l,$ns in b#t' tables t'at 'a(e t'e sa$e "#l,$nna$es in t'e #ined tables! T'e &es,ltin
#ined table "#ntains #nly #ne "#l,$n f#& ea"' %ai& #f e@,ally na$ed "#l,$ns!
M#st ex%e&ts a&ee t'at N+T4R+L JOINs a&e dane,s and t'e&ef#&e stnly dis"#,&ae t'ei&
,se! T'e dane& "#$es f$ inad(e&tently addin a ne) "#l,$n. na$ed t'e sa$e as an#t'e&
"#l,$n in t'e #t'e& table! +n existin nat,&al #in $i't t'en Dnat,&allyD ,se t'e ne) "#l,$n f#&
"#$%a&is#ns. $a5in "#$%a&is#nsG$at"'es ,sin diffe&ent "&ite&ia 8f$ diffe&ent "#l,$ns9 t'an
http://en.wikipedia.org/wiki/Join_(SQL)#Outer_joinshttp://en.wikipedia.org/wiki/Equality_(mathematics)http://en.wikipedia.org/wiki/SQL/92http://en.wikipedia.org/wiki/SQL/92http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-0http://en.wikipedia.org/wiki/Syntactic_sugarhttp://en.wikipedia.org/wiki/Natural_joinhttp://en.wikipedia.org/wiki/Natural_joinhttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-1http://en.wikipedia.org/wiki/Join_(SQL)#Outer_joinshttp://en.wikipedia.org/wiki/Equality_(mathematics)http://en.wikipedia.org/wiki/SQL/92http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-0http://en.wikipedia.org/wiki/Syntactic_sugarhttp://en.wikipedia.org/wiki/Natural_joinhttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-1
-
8/9/2019 Contoh Inner Join
12/24
bef#&e! T',s an existin @,e&y "#,ld %d,"e diffe&ent &es,lts. e(en t'#,' t'e data in t'e tables
'a(e n#t been "'aned. b,t #nly a,$ented!
T'e ab#(e sa$%le @,e&y f#& inne& #ins "an be ex%&essed as a nat,&al #in in t'e f#ll#)in )ay:
SELECT >FROM employeeN%TUR%L JOIN &epartment)
+s )it' t'e ex%li"it USIN: "la,se. #nly #ne ?e%a&t$entI? "#l,$n #"",&s in t'e #ined table.
)it' n# @,alifie&:
DepartmentID Emploee!LastName Department!DepartmentName
34 Smith 'leri$al
33 Jones )n,ineerin,
34 *o!inson 'leri$al
33 Stein!er, )n,ineerin,
31 *a+erty Sales
;#st&eSAL. MySAL and O&a"le s,%%#&t nat,&al #ins. b,t n#t Mi"s#ft TSAL #& I6M ?6!
T'e "#l,$ns ,sed in t'e #in a&e i$%li"it s# t'e #in "#de d#es n#t s'#) )'i"' "#l,$ns a&e
ex%e"ted. and a "'ane in "#l,$n na$es $ay "'ane t'e &es,lts! +n INNER JOIN %e&f#&$ed #n
tables 'a(in t'e sa$e field na$e 'as t'e sa$e effe"t! B
Cross joinCROSS JOIN &et,&ns t'e Ca&tesian %d,"t #f )s f$ tables in t'e #in! In #t'e& )#&ds. it )ill
%d,"e )s )'i"' "#$bine ea"' ) f$ t'e fi&st table )it' ea"' ) f$ t'e se"#nd table!K
Exa$%le #f an ex%li"it "ss #in:
SELECT >FROM employeeCROSS JOIN &epartment)
Exa$%le #f an i$%li"it "ss #in:
SELECT >FROM employee &epartment)
Emploee!Last
Name
Emploee!Depart
mentID
Department!Departm
entName
Department!Depart
mentID
*a+erty 31 Sales 31
http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-2http://en.wikipedia.org/wiki/Cartesian_producthttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-3http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-2http://en.wikipedia.org/wiki/Cartesian_producthttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-3
-
8/9/2019 Contoh Inner Join
13/24
Jones 33 Sales 31
Stein!er, 33 Sales 31
Smith 34 Sales 31
*o!inson 34 Sales 31
John NULL Sales 31
*a+erty 31 )n,ineerin, 33
Jones 33 )n,ineerin, 33
Stein!er, 33 )n,ineerin, 33
Smith 34 )n,ineerin, 33
*o!inson 34 )n,ineerin, 33
John NULL )n,ineerin, 33
*a+erty 31 'leri$al 34
Jones 33 'leri$al 34
Stein!er, 33 'leri$al 34
Smith 34 'leri$al 34
*o!inson 34 'leri$al 34
John NULL 'leri$al 34
*a+erty 31 .ar%etin, 3"
Jones 33 .ar%etin, 3"
Stein!er, 33 .ar%etin, 3"
Smith 34 .ar%etin, 3"
*o!inson 34 .ar%etin, 3"
John NULL .ar%etin, 3"
T'e "ss #in d#es n#t a%%ly any %&edi"ate t# filte& &e"#&ds f$ t'e #ined table! ;&a$$e&s
"an f,&t'e& filte& t'e &es,lts #f a "ss #in by ,sin a !ERE "la,se!
Outer /oins
-
8/9/2019 Contoh Inner Join
14/24
+n oute! 'oin d#es n#t &e@,i&e ea"' &e"#&d in t'e t)# #ined tables t# 'a(e a $at"'in &e"#&d!
T'e #ined table &etains ea"' &e"#&de(en if n# #t'e& $at"'in &e"#&d exists! O,te& #ins
s,bdi(ide f,&t'e& int# left #,te& #ins. &i't #,te& #ins. and f,ll #,te& #ins. de%endin #n )'i"'
table>s )s a&e &etained 8left. &i't. #& b#t'9!
8In t'is "ase left and right &efe& t# t'e t)# sides #f t'e JOIN 5ey)#&d!9
N# i$%li"it #inn#tati#n f#& #,te& #ins exists in standa&d SAL!
Le%t outer $oin
T'e &es,lt #f a left outer join 8#& si$%ly le$t 'oin9 f#& table + and 6 al)ays "#ntains all &e"#&ds #f
t'e DleftD table 8+9. e(en if t'e #in"#nditi#n d#es n#t find any $at"'in &e"#&d in t'e D&i'tD
table 869! T'is $eans t'at if t'e ON "la,se $at"'es 8e &e"#&ds in 6 8f#& a i(en &e"#&d in +9.
t'e #in )ill still &et,&n a ) in t'e &es,lt 8f#& t'at &e"#&d9b,t )it' N4LL in ea"' "#l,$n
f$ 6! + le$t oute! 'oin &et,&ns all t'e (al,es f$ an inne& #in %l,s all (al,es in t'e left table
t'at d# n#t $at"' t# t'e &i't table! F$ O&a"le Hi #n)a&ds t'e LEFT O4TER JOIN state$ent
"an be ,sed as )ell as O&a"le>s #lde& 89 syntax!
F#& exa$%le. t'is all#)s ,s t# find an e$%l#yee>s de%a&t$ent. b,t still s'#)s t'e e$%l#yee8s9
e(en )'en t'ey 'a(e n#t been assined t# a de%a&t$ent 8"#nt&a&y t# t'e inne&#in exa$%le
ab#(e. )'e&e ,nassined e$%l#yees )e&e ex"l,ded f$ t'e &es,lt9!
Exa$%le #f a left #,te& #in. )it' t'e additi#nal &es,lt ) 8"#$%a&ed )it' t'e inne& #in9
itali"ied:
SELECT >FROM employeeLEFT OUTER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID)
Emploee!Last
Name
Emploee!Depart
mentID
Department!Departm
entName
Department!Depart
mentID
Jones 33 )n,ineerin, 33
*a+erty 31 Sales 31
*o!inson 34 'leri$al 34
Smith 34 'leri$al 34
John NULL NULL NULL
Stein!er, 33 )n,ineerin, 33
O&a"le s,%%#&ts t'e alte&nate syntax:
http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-4http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-4
-
8/9/2019 Contoh Inner Join
15/24
SELECT > FROM employee &epartment !ERE employee.DepartmentID =&epartment.DepartmentID*?,
Sybase s,%%#&ts t'e alte&nate syntax:
SELECT > FROM employee &epartment !ERE employee.DepartmentID >=&epartment.DepartmentID
Ri&'t outer $oin
+ !ig&t oute! 'oin 8#& !ig&t 'oin9 "l#sely &ese$bles a left #,te& #in. ex"e%t )it' t'e t&eat$ent #f
t'e tables &e(e&sed! E(e&y ) f$ t'e D&i'tD table 869 )ill a%%ea& in t'e #ined table at least
#n"e! If n# $at"'in ) f$ t'e DleftD table 8+9 exists. N4LL )ill a%%ea& in "#l,$ns f$ +
f#& t'#se &e"#&ds t'at 'a(e n# $at"' in 6!
+ &i't #,te& #in &et,&ns all t'e (al,es f$ t'e &i't table and $at"'ed (al,es f$ t'e left
table 8N4LL in "ase #f n# $at"'in #in %&edi"ate9! F#& exa$%le. t'is all#)s ,s t# find ea"'
e$%l#yee and 'is #& 'e& de%a&t$ent. b,t still s'#) de%a&t$ents t'at 'a(e n# e$%l#yees!
6el#) is an exa$%le #f a &i't #,te& #in. )it' t'e additi#nal &es,lt ) itali"ied:
SELECT >FROM employeeRI:!T OUTER JOIN &epartment ON employee.DepartmentID =&epartment.DepartmentID)
Emploee!Last
Name
Emploee!Depart
mentID
Department!Departm
entName
Department!Depart
mentID
Smith 34 'leri$al 34
Jones 33 )n,ineerin, 33
*o!inson 34 'leri$al 34
Stein!er, 33 )n,ineerin, 33
*a+erty 31 Sales 31
NULL NULL Marketing 35
O&a"le s,%%#&ts t'e alte&nate syntax:
SELECT > FROM employee &epartment !ERE employee.DepartmentID*?, =&epartment.DepartmentID
Ri't and left #,te& #ins a&e f,n"ti#nally e@,i(alent! Neit'e& %(ides any f,n"ti#nality t'at t'e
#t'e& d#es n#t. s# &i't and left #,te& #ins $ay &e%la"e ea"' #t'e& as l#n as t'e table #&de& is
s)it"'ed!
-
8/9/2019 Contoh Inner Join
16/24
Full outer $oin
C#n"e%t,ally. a $ull oute! 'oin "#$bines t'e effe"t #f a%%lyin b#t' left and &i't #,te& #ins!
='e&e &e"#&ds in t'e F4LL O4TER JOINed tables d# n#t $at"'. t'e &es,lt set )ill 'a(e N4LL
(al,es f#& e(e&y "#l,$n #f t'e table t'at la"5s a $at"'in )! F#& t'#se &e"#&ds t'at d# $at"'. a
sinle ) )ill be %d,"ed in t'e &es,lt set 8"#ntainin fields %#%,lated f$ b#t' tables9!
F#& exa$%le. t'is all#)s ,s t# see ea"' e$%l#yee )'# is in a de%a&t$ent and ea"' de%a&t$ent
t'at 'as an e$%l#yee. b,t als# see ea"' e$%l#yee )'# is n#t %a&t #f a de%a&t$ent and ea"'
de%a&t$ent )'i"' d#esn>t 'a(e an e$%l#yee!
Exa$%le f,ll #,te& #in:
SELECT >FROM employeeFULL OUTER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID)
Emploee!Last
Name
Emploee!Depart
mentID
Department!Departm
entName
Department!Depart
mentID
Smith 34 'leri$al 34
Jones 33 )n,ineerin, 33
*o!inson 34 'leri$al 34
John NULL NULL NULL
Stein!er, 33 )n,ineerin, 33
*a+erty 31 Sales 31
NULL NULL Marketing 35
S#$e database syste$s d# n#t s,%%#&t t'e f,ll #,te& #in f,n"ti#nality di&e"tly. b,t t'ey "an
e$,late it t',' t'e ,se #f an inne& #in and 4NION +LL sele"ts #f t'e Dsinle table )sD
f$ left and &i't tables &es%e"ti(ely! T'e sa$e exa$%le "an a%%ea& as f#ll#)s:
SELECT employee.LastName employee.DepartmentID &epartment.DepartmentName&epartment.DepartmentIDFROM employeeINNER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID
UNION %LL SELECT employee.LastName employee.DepartmentID C%ST*NULL %S ;%RC!%R*8 FROM &epartment !ERE employee.DepartmentID =&epartment.DepartmentID, UNION %LL
-
8/9/2019 Contoh Inner Join
17/24
SELECT C%ST*NULL %S ;%RC!%R*8 FROM employee !ERE employee.DepartmentID =&epartment.DepartmentID,
Self0/oin
+ self#in is #inin a table t# itself!
Example
+ @,e&y t# find all %ai&ins #f t)# e$%l#yees in t'e sa$e "#,nt&y is desi&ed! If t'e&e )e&e t)#
se%a&ate tables f#& e$%l#yees and a @,e&y )'i"' &e@,ested e$%l#yees in t'e fi&st table 'a(in
t'e sa$e "#,nt&y as e$%l#yees in t'e se"#nd table. a n#&$al #in #%e&ati#n "#,ld be ,sed t# find
t'e ans)e& table! 3#)e(e&. all t'e e$%l#yee inf#&$ati#n is "#ntained )it'in a sinle la&e table!
C#nside& a $#dified Employee table s,"' as t'e f#ll#)in:
)mployee a!le
EmploeeID LastName Countr DepartmentID
123 *a+erty &ustralia 31
124 Jones &ustralia 33
14" Stein!er, &ustralia 33
2(1 *o!inson nited States 34
3(" Smith #ermany 34
3( John #ermany NULL
+n exa$%le s#l,ti#n @,e&y "#,ld be as f#ll#)s:
SELECT F.EmployeeID F.LastName S.EmployeeID S.LastName F.Co5ntryFROM Employee FINNER JOIN Employee S ON F.Co5ntry = S.Co5ntry!ERE F.EmployeeID 0 S.EmployeeIDORDER $A F.EmployeeID S.EmployeeID)
='i"' &es,lts in t'e f#ll#)in table bein ene&ated!
)mployee a!le after Self0/oin !y 'ountry
http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-5http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-6http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-5http://en.wikipedia.org/wiki/Join_(SQL)#cite_note-6
-
8/9/2019 Contoh Inner Join
18/24
EmploeeID LastName EmploeeID LastName Countr
123 *a+erty 124 Jones &ustralia
123 *a+erty 14" Stein!er, &ustralia
124 Jones 14" Stein!er, &ustralia
3(" Smith 3( John #ermany
F#& t'is exa$%le:
• F and S are aliases for the rst and se$ond $opies of the employee ta!le5
• he $ondition F.Co5ntry = S.Co5ntry e6$ludes pairin,s !etween employees indi+erent $ountries5 he e6ample 7uestion only wanted pairs of employees inthe same $ountry5
• he $ondition F.EmployeeID 0 S.EmployeeID e6$ludes pairin,s where theEmployeeID of the rst employee is ,reater than or e7ual to the EmployeeID ofthe se$ond employee5 In other words8 the e+e$t of this $ondition is to e6$ludedupli$ate pairin,s and self0pairin,s5 9ithout it8 the followin, less useful ta!lewould !e ,enerated :the ta!le !elow displays only the ;#ermany; portion ofthe result
-
8/9/2019 Contoh Inner Join
19/24
#& t'e "&eati#n #f an a&eate f,n"ti#n!
sin, the )mployee a!le=
LastName DepartmentID
*a+erty 31
Jones 33
Stein!er, 33
*o!inson 34
Smith 34
John NULL
to a$hie>e the followin, results a!le
DepartmentID LastNames
NULL John
31 *a+erty
33 Jones8 Stein!er,
34 *o!inson8 Smith
(SQLSELECT DepartmentID 4ro5pBconcat*LastName, %S LastNamesFROM employee:ROUP $A DepartmentID)
)racle **& R+SELECT DepartmentID l"sta44*LastName # #, IT!IN :ROUP *ORDER $A LastName, %S LastNamesFROM employee:ROUP $A DepartmentID)
CU,RIDSELECT DepartmentID :ROUPBCONC%T*LastName ORDER $A LastName SEP%R%TOR ##, %SLastNamesFROM employee:ROUP $A DepartmentID)
-
8/9/2019 Contoh Inner Join
20/24
-ost&reSQL
his se$tion ma stra %rom t'e topic o% t'e article5 ?lease help impro>e
this se$tion or dis$uss this issue on the tal% pa,e5 (May 2012)
Fi&st t'e f,n"ti#n P,%P"#n"at and a&eate ,%P"#n"at need t# be "&eated bef#&e t'at
@,e&y "an be %#ssible!
CRE%TE OR REPL%CE FUNCTION B4ro5pBconcat*tet tet,RETURNS tet %S SELECT C%SE!EN 8 IS NULL T!EN 7!EN 7 IS NULL T!EN 8ELSE 7 operator*p4Bcatalo4., # # operator*p4Bcatalo4., 8END IMMUT%$LE L%N:U%:E SGL) errorHH JOIN SGLCRE%TE %::RE:%TE 4ro5pBconcat *
$%SETAPE = tetSFUNC = B4ro5pBconcatSTAPE = tet,) SELECT DepartmentID 4ro5pBconcat*LastName, %S LastNamesFROM employee:ROUP $A DepartmentID)
+s f#& (e&si#n H!:
SELECT DepartmentID str"n4Ba44*LastName # #, %S LastNamesFROM employee:ROUP $A DepartmentID)
(icroso%t T#SQL
his se$tion ma stra %rom t'e topic o% t'e article5 ?lease help impro>e
this se$tion or dis$uss this issue on the tal% pa,e5 (May 2012)
F#& (e&si#ns %&i#& t# Mi"s#ft SAL Se&(e& . t'e f,n"ti#n ,%P"#n"at $,st be "&eated as a
,se&defined a&eate f,n"ti#n bef#&e t'at @,e&y "an be %#ssible. s'#)n 'e&e in C!
5s"n4 System)5s"n4 System.Collect"ons.:ener"c)5s"n4 System.Data.SlTypes)5s"n4 System.IO)5s"n4 M"croso-t.SlSerer.Serer) Ser"al"Ka6leSlUserDe-"ne&%44re4ate*Format.UserDe-"ne& Ma$yteS"Ke=
-
8/9/2019 Contoh Inner Join
21/24
p56l"c o"& %cc5m5late*SlStr"n4 al5e, t"s.al5es.%&&*al5e.;al5e,) p56l"c o"& Mer4e*strconcat al5e, t"s.al5es.%&&Ran4e*al5e.al5es.To%rray*,,) p56l"c SlStr"n4 Term"nate*, ret5rn ne' SlStr"n4*str"n4.Jo"n*Q Q t"s.al5es.To%rray*,,,) p56l"c o"& Rea&*$"naryRea&er r, "nt "temCo5nt = r.Rea&Int38*,) t"s.al5es = ne' L"st*"temCo5nt,) -or *"nt " =
-
8/9/2019 Contoh Inner Join
22/24
<ernati>es
T'e effe"t #f an #,te& #in "an als# be #btained ,sin a 4NION +LL bet)een an INNER JOIN
and a SELECT #f t'e )s in t'e D$ainD table t'at d# n#t f,lfill t'e #in "#nditi#n! F#& exa$%le
SELECT employee.LastName employee.DepartmentID &epartment.DepartmentNameFROM employeeLEFT OUTER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID)
"an als# be )&itten as
SELECT employee.LastName employee.DepartmentID &epartment.DepartmentNameFROM employeeINNER JOIN &epartment ON employee.DepartmentID = &epartment.DepartmentID UNION %LL SELECT employee.LastName employee.DepartmentID C%ST*NULL %S ;%RC!%R*8 FROM &epartment !ERE employee.DepartmentID =&epartment.DepartmentID,
Implementation
M,"' )#&5 in databasesyste$s 'as ai$ed at effi"ient i$%le$entati#n #f #ins. be"a,se
&elati#nal syste$s "#$$#nly "all f#& #ins. yet fa"e diffi",lties in #%ti$isin t'ei& effi"ient
exe",ti#n! T'e %ble$ a&ises be"a,se inne& #ins #%e&ate b#t' "#$$,tati(ely and ass#"iati(ely!
In %&a"ti"e. t'is $eans t'at t'e ,se& $e&ely s,%%lies t'e list #f tables f#& #inin and t'e #in
"#nditi#ns t# ,se. and t'e database syste$ 'as t'e tas5 #f dete&$inin t'e $#st effi"ient )ay t#
%e&f#&$ t'e #%e&ati#n! + @,e&y #%ti$ie& dete&$ines '#) t# exe",te a @,e&y "#ntainin #ins! +
@,e&y #%ti$ie& 'as t)# basi" f&eed#$s:
15 .oin order= Be$ause it /oins fun$tions $ommutati>ely and asso$iati>ely8 theorder in whi$h the system /oins ta!les does not $han,e the nal result0set ofthe 7uery5 Howe>er8 /oin0order could ha>e an enormous impa$t on the $ost of the /oin operation8 so $hoosin, the !est /oin order !e$omes >ery important5
25 .oin met'od= #i>en two ta!les and a /oin $ondition8 multiple al,orithms $anprodu$e the result0set of the /oin5 9hi$h al,orithm runs most e@$ientlydepends on the sies of the input ta!les8 the num!er of rows from ea$h ta!lethat mat$h the /oin $ondition8 and the operations re7uired !y the rest of the7uery5
Many #inal#&it'$s t&eat t'ei& in%,ts diffe&ently! One "an &efe& t# t'e in%,ts t# a #in as t'e
D#,te&D and Dinne&D #in #%e&ands. #& DleftD and D&i'tD. &es%e"ti(ely! In t'e "ase #f nested l##%s.
f#& exa$%le. t'e database syste$ )ill s"an t'e enti&e inne& &elati#n f#& ea"' ) #f t'e #,te&
&elati#n!
One "an "lassify @,e&y%lans in(#l(in #ins as f#ll#)s:
http://en.wikipedia.org/wiki/Commutativehttp://en.wikipedia.org/wiki/Associativehttp://en.wikipedia.org/wiki/Associativehttp://en.wikipedia.org/wiki/Query_optimizerhttp://en.wikipedia.org/wiki/Query_optimizerhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-Yu1998-7http://en.wikipedia.org/wiki/Commutativehttp://en.wikipedia.org/wiki/Associativehttp://en.wikipedia.org/wiki/Query_optimizerhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-Yu1998-7
-
8/9/2019 Contoh Inner Join
23/24
left0deep
usin, a !ase ta!le :rather than another /oin< as the inner operand of ea$h /oin
in the plan
ri,ht0deep
usin, a !ase ta!le as the outer operand of ea$h /oin in the plan
!ushy
neither left0deep nor ri,ht0deepA !oth inputs to a /oin may themsel>es result
from /oins
T'ese na$es de&i(e f$ t'e a%%ea&an"e #f t'e @,e&y %lan if d&a)n as a t&ee. )it' t'e #,te& #in
&elati#n #n t'e left and t'e inne& &elati#n #n t'e &i't 8as "#n(enti#n di"tates9!
.oin al&orit'msT'&ee f,nda$ental al#&it'$s f#& %e&f#&$in a #in #%e&ati#n a&e 5n#)n: Nested l##% #in. S#&t
$e&e #in and 3as' #in!
.oin Indexes
J#in indexes a&e database indexes t'at fa"ilitate t'e %"essin #f #in @,e&ies in data
)a&e'#,ses: t'ey a&e ",&&ently 819 a(ailable in i$%le$entati#ns by O&a"leH and Te&adata!1
In t'e Te&adata i$%le$entati#n. s%e"ified "#l,$ns. a&eate f,n"ti#ns #n "#l,$ns. #&
"#$%#nents #f date "#l,$ns f$ #ne #& $#&e tables a&e s%e"ified ,sin a syntax si$ila& t# t'e
definiti#n #f a database (ie): ,% t# K "#l,$nsG"#l,$n ex%&essi#ns "an be s%e"ified in a sinle #in index! O%ti#nally. a "#l,$n t'at defines t'e %&i$a&y 5ey #f t'e "#$%#site data $ay als# be
s%e"ified: #n %a&allel 'a&d)a&e. t'e "#l,$n (al,es a&e ,sed t# %a&titi#n t'e index>s "#ntents
a"ss $,lti%le dis5s! ='en t'e s#,&"e tables a&e ,%dated inte&a"ti(ely by ,se&s. t'e "#ntents #f
t'e #in index a&e a,t#$ati"ally ,%dated! +ny @,e&y )'#se =3ERE "la,se s%e"ifies any
"#$binati#n #f "#l,$ns #& "#l,$n ex%&essi#ns t'at a&e an exa"t s,bset #f t'#se defined in a #in
index 8a s#"alled D"#(e&in @,e&yD )ill "a,se t'e #in index. &at'e& t'an t'e #&iinal tables and
t'ei& indexes. t# be "#ns,lted d,&in @,e&y exe",ti#n!
T'e O&a"le i$%le$entati#n li$its itself t# ,sin bit$a% indexes! + bitmap join index is ,sed f#&
l#)"a&dinality "#l,$ns 8i!e!. "#l,$ns "#ntainin less t'an B distin"t (al,es. a""#&din t# t'eO&a"le d#",$entati#n9: it "#$bines l#)"a&dinality "#l,$ns f$ $,lti%le &elated tables! T'e
exa$%le O&a"le ,ses is t'at #f an in(ent#&y syste$. )'e&e diffe&ent s,%%lie&s %(ide diffe&ent
%a&ts! T'e s"'e$a 'as t'&ee lin5ed tables: t)# D$aste& tablesD. ;a&t and S,%%lie&. and a Ddetail
tableD. In(ent#&y! T'e last is a $anyt#$any table lin5in S,%%lie& t# ;a&t. and "#ntains t'e
$#st )s! E(e&y %a&t 'as a ;a&t Ty%e. and e(e&y s,%%lie& is based in t'e 4S+. and 'as a State
"#l,$n! T'e&e a&e n#t $#&e t'an stateste&&it#&ies in t'e 4S+. and n#t $#&e t'an B ;a&t
http://en.wikipedia.org/wiki/Query_planhttp://en.wikipedia.org/wiki/Tree_data_structurehttp://en.wikipedia.org/wiki/Tree_data_structurehttp://en.wikipedia.org/wiki/Nested_loop_joinhttp://en.wikipedia.org/wiki/Sort-merge_joinhttp://en.wikipedia.org/wiki/Sort-merge_joinhttp://en.wikipedia.org/wiki/Sort-merge_joinhttp://en.wikipedia.org/wiki/Hash_joinhttp://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Data_warehousehttp://en.wikipedia.org/wiki/Data_warehousehttp://en.wikipedia.org/wiki/Oraclehttp://en.wikipedia.org/wiki/Oraclehttp://en.wikipedia.org/wiki/Oraclehttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-8http://en.wikipedia.org/wiki/Teradatahttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-9http://en.wikipedia.org/wiki/Database_viewhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Where_(SQL)http://en.wikipedia.org/wiki/Bitmap_indexhttp://en.wikipedia.org/wiki/Bitmap_indexhttp://en.wikipedia.org/wiki/Query_planhttp://en.wikipedia.org/wiki/Tree_data_structurehttp://en.wikipedia.org/wiki/Nested_loop_joinhttp://en.wikipedia.org/wiki/Sort-merge_joinhttp://en.wikipedia.org/wiki/Sort-merge_joinhttp://en.wikipedia.org/wiki/Hash_joinhttp://en.wikipedia.org/wiki/Database_indexhttp://en.wikipedia.org/wiki/Data_warehousehttp://en.wikipedia.org/wiki/Data_warehousehttp://en.wikipedia.org/wiki/Oraclehttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-8http://en.wikipedia.org/wiki/Teradatahttp://en.wikipedia.org/wiki/Join_(SQL)#cite_note-9http://en.wikipedia.org/wiki/Database_viewhttp://en.wikipedia.org/wiki/Primary_keyhttp://en.wikipedia.org/wiki/Where_(SQL)http://en.wikipedia.org/wiki/Bitmap_index
-
8/9/2019 Contoh Inner Join
24/24
Ty%es! T'e bit$a% #in index is defined ,sin a standa&d t'&eetable #in #n t'e ab#(e t'&ee
tables. and s%e"ifyin t'e ;a&tPTy%e and S,%%lie&PState "#l,$ns f#& t'e index! 3#)e(e&. it is
defined #n t'e In(ent#&y table. e(en t'#,' t'e "#l,$ns ;a&tPTy%e and S,%%lie&PState a&e
Db#&)edD f$ S,%%lie& and ;a&t &es%e"ti(ely!
+s f#& Te&adata. an O&a"le bit$a% #in index is #nly ,tilied t# ans)e& a @,e&y )'en t'e @,e&y>s
=3ERE "la,se s%e"ifies "#l,$ns li$ited t# t'#se t'at a&e in"l,ded in t'e #in inde
http://en.wikipedia.org/wiki/Where_(SQL)http://en.wikipedia.org/wiki/Where_(SQL)
top related