I want records from ip which are not in a DHCP range. The ip table has over ten thousand records, the ranges about thousand.
CREATE TABLE ip (ip int);
CREATE TABLE dhcprange (start int,end int);
INSERT INTO found_ips VALUES
(INET_ATON('10.0.0.10')),
(INET_ATON('10.0.0.11')),
(INET_ATON('10.0.0.12')),
(INET_ATON('10.0.0.51')),
(INET_ATON('10.0.0.52')
);
INSERT INTO dhcpranges VALUES
(INET_ATON('10.0.0.50'),INET_ATON('10.0.0.60'),
(INET_ATON('10.0.0.70'),INET_ATON('10.0.0.100')
);
(This unfortunately does not work on sqlfiddle (inet_aton isn’t supported?))
This doesn’t work:
SELECT ip FROM ip WHERE ip NOT BETWEEN(SELECT start,end FROM dhcprange)
Ideas?
1 Answer