あなたがこれを望んでいるように聞こえますが、これはあなたが望む結果ではない可能性が最も高いデカルト結果を生成しようとしています:
SELECT COUNT(*)
FROM `zz_tview`,`zz_tview1`,`zz_tview3`
WHERE `zz_tview`.`ipaddress` ="192.168.01.01"
OR `zz_tview1`.`ipaddress` ="192.168.01.01"
OR `zz_tview3`.`ipaddress` ="192.168.01.01"
これを次のように構築する必要がありますJOIN
。
SELECT COUNT(*)
FROM `zz_tview` v
INNER JOIN `zz_tview1` v1
ON v.id = v1.id --- use the column that would join these values
INNER JOIN `zz_tview3` v3
ON v.id = v3.id --- use the column that would join these values
WHERE v.`ipaddress` ="192.168.01.01"
OR v1.`ipaddress` ="192.168.01.01"
OR v3.`ipaddress` ="192.168.01.01"
テーブルにアクセスできない場合は、次のJOIN
ようなものを使用できます。
select sum(total)
from
(
SELECT count(*) as `total`
FROM `zz_tview` v
where v.`ipaddress` ="192.168.01.01"
union all
SELECT count(*) as `total`
FROM `zz_tview1` v1
where v1.`ipaddress` ="192.168.01.01"
union all
SELECT count(*) as `total`
FROM `zz_tview3` v3
where v3.`ipaddress` ="192.168.01.01"
) src