We're Moving!

The Vertica Forum is moving to a new OpenText Analytics Database (Vertica) Community.

Join us there to post discussion topics, learn about

product releases, share tips, access the blog, and much more.

Create My New Community Account Now


Joining table on a range — Vertica Forum

Joining table on a range

Hello,

I have a rather rare issue. I have 2 tables. Let's call them IP and ICP. These tables hold IP addresses. I need to join these 2 tables, but my only join condition is a range of IP's.

Let me explain...

In table IP we have a column called IPAddress. It's self explanatory what this column contains. In the ICP table there are 2 columns... IPAddress_start and IPAddress_end. So, I need to join the IPAddress from the IP table to the range between IPAddress_start and IPAddress end.

I have tried the following that hasn't worked. I also tried SUBQUERIES, but the query returns more than 1 row so I get an error message.

Any help would be greatly appreciated.

SELECT * FROM IP
JOIN ICP
ON IP.IPAddress >= ICP.IPAddress_start
OR IP.IPAddress <= ICP.IPAddress_end;

SELECT * FROM IP
WHERE EXISTS (SELECT * FROM ICP WHERE
IP.IPAddress >= ICP.IPAddress_start OR
IP.IPAddress <= ICP.IPAddress_end);

Comments

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file