5种数据库sql语句大全六完结数据库20080825151107阅读13评论0字号:大中小订阅r
r
一一六、表达父母孩子关系r
db2oraclepostgresqlr
selectae
ameworksforbe
ameasemps_a
d_mgrsfromempaempbwhereamgrr
r
bemp
or
r
mysqlr
selectco
catae
ameworksforbe
ameasemps_a
d_mgrsfromempaempbwhereamgrr
r
bemp
or
r
sqlserverr
selectae
ameworksforbe
ameasemps_a
d_mgrsfromempaempbwhereamgrr
r
bemp
or
r
一一七、表达孩子父母祖父母之间的关系r
db2sqlserverr
withxtreemgrdepthasselectcaste
ameasvarchar100mgr0fromempwherer
r
e
ameMILLERu
io
allselectcastxtreeee
ameasvarchar100emgrr
r
xdepth1fromempexwherexmgreemp
or
selecttreeleaf___bra
ch___rootfromxwheredepth2r
r
oracler
selectltrimsys_co
ect_by_pathe
ameleaf___bra
ch___rootfromempwherer
r
level3startwithe
ameMILLERco
ectbypriormgremp
or
r
postgresqlmysqlr
selectae
amebe
amece
ameasleaf___bra
ch___rootfromempaempbr
r
empcwhereae
ameMILLERa
damgrbemp
oa
dbmgrcemp
or
r
一一八、创建表的一个层次视图r
db2sqlserverr
withxe
ameemp
oasselectcaste
ameasvarchar100emp
ofromempwheremgris
ullr
r
u
io
allselectcastxe
ameee
ameasvarchar100eemp
ofromempexwherer
r
emgrxemp
or
selecte
ameasemp_treefromxorderby1r
r
oracler
selectltrimsys_co
ect_by_pathe
ameemp_treefromempstartwithmgrisr
r
ullco
ectbyprioremp
omgrorderby1r
r
postgresqlr
selectemp_treefromselecte
ameasemp_treefromempwheremgris
ullu
io
selectr
r
ae
amebe
amefromempajoi
empbo
aemp
obmgrwhereamgris
ullu
io
r
r
selectrtrimae
amebe
amece
amefromempajoi
empbo
r
r
aemp
obmgrleftjoi
empco
bemp
ocmgrwhereae
ameKINGu
io
selectr
r
rtrimae
amebe
amece
amede
amefromempajoi
empbr
r
o
aemp
obmgrjoi
empco
bemp
ocmgrleftjoi
empdo
cemp
odmgrwherer
r
ae
ameKINGxwheretreeis
ot
ullorderby1r
r
mysqlr
selectemp_treefromselecte
ameasemp_treefromempwheremgris
ullu
io
selectr
r
co
catae
amebe
amefromempajoi
empbo
aemp
obmgrwhereamgris
ullr
r
u
io
selectco
catae
amebe
amece
amefromempajoi
empbo
r
r
aemp
obmgrleftjoi
empco
bemp
ocmgrwhereae
ameKINGu
io
selectr
r
co
catae
amebe
amece
amede
amefromempajoi
empbo
r
r
aemp
obmgrjoi
empco
bemp
ocmgrleftjoi
empdo
cemp
odmgrwherer
r
ae
ameKINGxwheretreeis
ot
ullorderby1r
r
一一九、找出由给出的父列确定所有子列r
db2sqlserverr
withxe
ameemp
or