Re: Join on a where clause.

2009-12-12 Thread Shawn Green
Hello Paul, Paul Halliday wrote: I have 2 tables: 1) Event Data 2) Mappings The query should return something like this: Hits IP Country Code 20213.136.52.29 SE I am trying this: SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), mappings.cc

Re: Join on a where clause.

2009-12-11 Thread Joerg Bruehe
Hi Paul, all! Paul Halliday wrote: > On Wed, Dec 9, 2009 at 2:24 PM, Joerg Bruehe wrote: >> Hi everybody! >> >> >> Neil Aggarwal wrote: >>> Paul: >>> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN '2009-

Re: Join on a where clause.

2009-12-10 Thread Andy Wallace
A couple of thoughts - it's not "no quotes on integers", but "no quotes around column references". When you use 'mappings.end_ip', you are saying "the string mappings.end_ip", and not referring to a column in the mappings table. It just becomes a constant at that point. As for the performance, yo

Re: Join on a where clause.

2009-12-10 Thread Paul Halliday
On Wed, Dec 9, 2009 at 2:24 PM, Joerg Bruehe wrote: > Hi everybody! > > > Neil Aggarwal wrote: >> Paul: >> >>> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), >>> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN >>> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event

RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Joerg: > A matching column is called an "equijoin" > However, that is not mandatory / the only form. > As long as the problem can be solved using ranges (or multiple ranges) > which do not overlap, the join should solve it. I just learned something. Thanks for the info! Neil -- Neil Agg

Re: Join on a where clause.

2009-12-09 Thread Joerg Bruehe
Hi everybody! Neil Aggarwal wrote: > Paul: > >> SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), >> mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN >> '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN >> 'mappings.start_ip' AND 'mappings.end_ip' GR

RE: Join on a where clause.

2009-12-09 Thread Neil Aggarwal
Paul: > SELECT COUNT(event.src_ip) AS count, INET_NTOA(event.src_ip), > mappings.cc FROM event, mappings WHERE event.timestamp BETWEEN > '2009-12-06 20:00' and '2009-12-07 20:00:00' AND event.src_ip BETWEEN > 'mappings.start_ip' AND 'mappings.end_ip' GROUP BY event.src_ip ORDER > BY count DESC LIM