我有一个(postgres)sql 表,其中包含以下内容(主机):
ip_address | mac_address | hostname | device | physical_port
----------------+----------------+----------+--------+---------------
111.111.111.111 | aaaa.aaaa.aaaa | hosta | swh-a | Gi1/1
111.111.111.112 | bbbb.bbbb.bbbb | hostb | swh-b | Gi2/1
111.111.111.113 | cccc.cccc.cccc | hostc | swh-c | Gi3/1
devices
我有另一个表(Peers),其中包含在able 表中的点对点链接。
device | physical_port | peer_device | peer_physical_port
-------+---------------+-------------+----------------------+
swh-a | Gi1/20 | swh-b | Gi2/1
swh-b | Gi2/1 | swh-a | Gi1/20
swh-b | Gi2/1 | swh-c | Gi3/1
swh-c | Gi3/1 | swh-b | Gi2/1
基本上,我希望从 Hosts 表中排除包含在 Peers 表中的条目,这样我只能得到:
ip_address | mac_address | hostname | device | physical_port
----------------+----------------+----------+--------+---------------
111.111.111.111 | aaaa.aaaa.aaaa | hosta | swh-a | Gi1/1
(鉴于此device=swh-b physical_port=Gi2/1
并且device=swh-c physical_port=Gi3/1
存在于 Peers 表中)。