mysql多表联合查询 去重_mysql中的多表联合并且去重排序
同一數(shù)據(jù)庫中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
");
總結(jié)
以上是生活随笔為你收集整理的mysql多表联合查询 去重_mysql中的多表联合并且去重排序的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: csrss.exe
- 下一篇: 制作种子怎么上传服务器,怎么制作BT种子