Ich habe die folgende SQL-Abfrage, aber wenn ich ausführe Es gibt mir eine Fehlermeldung: Unknown column 't1.ip' in 'where clause'
. Wenn ich t1.ip
in Unterabfrage nur zum Testen hart Code, funktioniert es perfekt.Update mit Unterabfrage nicht relationalen Tabelle
UPDATE
report_a t1,
(SELECT
location.country, region.name, location.city
FROM
geoip
INNER JOIN
location
ON
geoip.locId = location.locId
INNER JOIN
region
ON
region.country = location.country
AND
region.region = location.region
WHERE
INET_ATON(t1.ip) BETWEEN startIpNum AND endIpNum
LIMIT 1) AS t2
SET
t1.country = t2.country,
t1.city = t2.city,
t1.state = t2.name;
Jemand hat eine Idee, wie ich diese Abfrage tun kann?
Dank
Es funktioniert fast! Ich habe das 'ON' in' WHERE' geändert. "LIMIT 1" zu verwenden war eine Empfehlung des Herstellers, aber ich denke, es sollte nicht mehrere Übereinstimmungen haben. – Guhh