【发布时间】:2012-11-21 14:40:03
【问题描述】:
例如,我有两个数据表:
网络状态
ipaddress time violation
192.168.1.1 2:00 yes
192.168.1.6 2:00 no
192.168.1.11 2:00 no
192.168.1.1 3:00 no
192.168.1.6 3:00 no
192.168.1.11 3:00 yes
和
防火墙日志
ipaddress machinetype location
192.168.1.1 computer London
192.168.1.6 server New York
192.168.1.11 server Bejing
我希望将防火墙日志中的数据合并到网络状态表中,以便获得以下信息:
网络状态
ipaddress time violation machinetype location
192.168.1.1 2:00 yes computer London
192.168.1.6 2:00 no server New York
192.168.1.11 2:00 no server Bejing
192.168.1.1 3:00 no computer London
192.168.1.6 3:00 no server New York
192.168.1.11 3:00 yes server Bejing
有人有什么想法吗?我假设会有一个命令通过特定的列值合并表,但经过研究,我只遇到了 join 和 select into 命令。但我不知道如何使用这些来实现我想要的。
谢谢!
【问题讨论】:
-
UNION 不起作用,不同的列数
标签: sql postgresql