前提是tab1和tab2都要有对应的numb
如何比较2个mysql数据库数据sql语句:因为MySQL 没有full outer join,所以用left join union all right join来实现
select a.table_schema,
a.table_name,
a.column_name,
b.table_schema,
b.table_name,
b.column_name
from information_schema.columns a
left join information_schema.columns b on a.table_name = b.table_name and a.column_name =
b.column_name andb.table_schema = 'DBNAMe1'
where a.table_schema = 'DBNAME2' and
(b.table_name is null or
b.column_name is null)
union all
select a.table_schema,
a.table_name,
a.column_name,
b.table_schema,
b.table_name,
b.column_name
from information_schema.columns a
left join information_schema.columns b on a.table_name = b.table_name and a.column_name =
b.column_name andb.table_schema = 'DBNAME2'
where a.table_schema = 'DBNAME1' and
(b.table_name is null or
b.column_name is NULL)
写了一个比较ip地址前半部分的函数,以你给的两个ip为例:<?php
function ip_part_same($ip1, $ip2) {
$ip1_arr = explode('.', $ip1)
$ip1_f2 = $ip1_arr[0] . $ip1_arr[1]
$ip2_arr = explode('.', $ip2)
$ip2_f2 = $ip2_arr[0] . $ip2_arr[1]
return ($ip1_f2 == $ip2_f2) ? true : false
}
$ip1 = '218.64.81.38'
$ip2 = '183.59.40.203'
if (ip_part_same($ip1, $ip2)) {
echo "ip1和ip2前半部分相同\n"
} else {
echo "ip1和ip2前半部分不同\n"
}
?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)