List:General Discussion« Previous MessageNext Message »
From:Nathan Sullivan Date:October 12 2010 12:48pm
Subject:Re: Can this be done with a single query?
View as plain text  
Paul,

I think you could accomplish this by adding a subquery to your where clause, like:

AND NOT EXISTS (SELECT * FROM mappings m where m.src_ip=src_ip)


Hope that helps.


Nathan


On Tue, Oct 12, 2010 at 03:19:36AM -0700, Paul Halliday wrote:
> I have 2 tables: events and mappings.
> 
> what I want to do is something like:
> 
> SELECT DISTINCT(src_ip) FROM event WHERE timestamp BETWEEN '2010-10-11
> 00:00:00' AND '2010-10-12 00:00:00' AND INET_NTOA(src_ip) NOT LIKE
> '10.%.%.%' AND INET_NTOA(src_ip) NOT LIKE '172.16.%.%' AND INET_NTOA(src_ip)
> NOT LIKE '192.168.%.%';
> 
> but, within that somewhere also check to see if src_ip exists in mappings.
> If it does, do not return it.
> 
> Is this possible?
> 
> Thanks.
> -- 
> Paul Halliday
> Ideation | Individualization | Learner | Achiever | Analytical
> http://www.pintumbler.org
Thread
Can this be done with a single query?Paul Halliday12 Oct
  • Re: Can this be done with a single query?Nathan Sullivan12 Oct
  • Re: Can this be done with a single query?Johnny Withers12 Oct
    • Re: Can this be done with a single query?Paul Halliday12 Oct
      • RE: Can this be done with a single query?Travis Ard12 Oct
        • RE: Can this be done with a single query?Daevid Vincent13 Oct