Print Page | Close Window

One of each occurence from table

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=17615
Printed Date: 29 March 2026 at 10:14am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: One of each occurence from table
Posted By: pedalcars
Subject: One of each occurence from table
Date Posted: 22 December 2005 at 3:21pm
I have a table of IP addresses and DNS names (of failed hackers, as it happens).

I want to search by DNS name (or part), eg, yetanotherhacker1234.ttnet.net.tr, or just *ttnet.net.tr and find all IP addresses matching that DNS.

However, that could bring back hundreds if not thousands of results, particularly in the case of scripted attacks where there may be 500 or more failed attacks from the same IP address.

So, I want only to see one instance of each IP address for each DNS, eg:

ttnet.net.tr -> 11.22.33.44
ttnet.net.tr -> 11.22.44.66
ttnet.net.tr -> 11.22.55.88

Obviously this could be done by finding all records for the DNS, ordered by IP address, then looping through them and only displaying a record if the IP differed from the previous record. However that seems very inefficient, particularly when there may be thousands of records.

So I need a better way - any solutions gratefully received.

Ta.

-------------
http://www.pedalcars.info/ - www.pedalcars.info

The most fun on four wheels




Replies:
Posted By: jeffdaro
Date Posted: 22 December 2005 at 3:25pm
Use SELECT DISTINCT.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net