mysql多表联合查询 去重_mysql中的多表联合并且去重排序
同一數據庫中au_log_開頭的表,表中ipsrc和ipdst、portsrc和portdst字段將這些4元組去重后顯示出來,并按照某個字段排序
$result = $db->query("
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_baseline where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst )
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_ics_pro where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_ics_wl where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_ip_bl where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_mac_bl where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_noflow where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_system where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_tcp where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_udp where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
UNION
(SELECT ipsrc,ipdst,portsrc,portdst FROM au_log_user where node_name = '".$deviceName."' group by ipsrc,ipdst,portsrc,portdst)
order by ipsrc asc
");
總結
以上是生活随笔為你收集整理的mysql多表联合查询 去重_mysql中的多表联合并且去重排序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: csrss.exe
- 下一篇: MySQL 新增、修改、删除 字段 sq