SQL,CUCM:查询 returns 没有结果
SQL, CUCM: query returns with no result
在 CUCM (11.5) cli returns 中进行以下 SQL 查询,结果如下:
device number loggedin_to_lg linegroup
=============== =============== ============== ======================================
CSFABCDEF \+49325874147 f LG-HG_BER01_49325874147
CSFRFETRS \+49325800848 f LG-HG_BER01_493225800848
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
order by lg.name
但是,如果我们尝试将另一个 table -extensionmobilitydynamic- 内连接到此查询并显示其列之一,它 returns 没有结果。
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup, e.datetimestamp
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
inner join extensionmobilitydynamic as e on e.fkdevice = d.pkid
order by lg.name
它没有找到任何匹配的行,因此 INNER JOIN 无法检索到任何内容。您必须为新的 table 尝试 left join,其中可能没有匹配结果。在这种情况下,结果列将为 NULL。
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup, e.datetimestamp
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
left join extensionmobilitydynamic as e on e.fkdevice = d.pkid
order by lg.name
在 CUCM (11.5) cli returns 中进行以下 SQL 查询,结果如下:
device number loggedin_to_lg linegroup
=============== =============== ============== ======================================
CSFABCDEF \+49325874147 f LG-HG_BER01_49325874147
CSFRFETRS \+49325800848 f LG-HG_BER01_493225800848
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
order by lg.name
但是,如果我们尝试将另一个 table -extensionmobilitydynamic- 内连接到此查询并显示其列之一,它 returns 没有结果。
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup, e.datetimestamp
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
inner join extensionmobilitydynamic as e on e.fkdevice = d.pkid
order by lg.name
它没有找到任何匹配的行,因此 INNER JOIN 无法检索到任何内容。您必须为新的 table 尝试 left join,其中可能没有匹配结果。在这种情况下,结果列将为 NULL。
run sql select d.name as Device, n.dnorpattern as Number, dhd.hlog as LoggedIn_to_LG, lg.name as LineGroup, e.datetimestamp
from linegroup as lg
inner join linegroupnumplanmap as lgmap on lgmap.fklinegroup=lg.pkid
inner join numplan as n on lgmap.fknumplan = n.pkid
inner join devicenumplanmap as dmap on dmap.fknumplan=n.pkid
inner join device as d on dmap.fkdevice=d.pkid
inner join devicehlogdynamic as dhd on dhd.fkdevice=d.pkid
left join extensionmobilitydynamic as e on e.fkdevice = d.pkid
order by lg.name