我正在使用以下查询,但我希望对于WHERE子句中的每个条目,即使对于同一子网中的那些条目,我也会得到结果。在我的情况下,如果两个IP位于同一子网中,则结果返回一个元组。我想,对于我拥有的每个IP,都会重新调整元组。有人可以帮忙吗?
SELECT name, ipstart ,prefix , <ip_seached_for>
FROM ip
JOIN countries
ON ip.sid = countries.sid WHERE (
(INET_ATON('125.235.51.241') between ipstartdec and ipenddec) OR
(INET_ATON('125.235.51.200') between ipstartdec and ipenddec) OR
(INET_ATON('116.79.199.160') between ipstartdec and ipenddec)
)
表格结构:
**IP**
sid ipstart prefix ipend maskdec ipstartdec ipenddec
2 79.106.255.64 28 79.106.255.79 4294967280 1332412224 1332412239
4 194.158.95.192 28 194.158.95.207 4294967280 3265159104 3265159119
4 194.158.95.208 28 194.158.95.223 4294967280 3265159120 3265159135
4 194.158.95.224 27 194.158.95.255 4294967264 3265159136 3265159167
**Countries**
SID Name
2 Albania
3 Algeria
4 Andorra
5 Aruba
6 Argentina
7 Argentina