[NBLUG/talk] SQL statement
Walter Hansen
gandalf at sonic.net
Thu Aug 19 12:19:28 PDT 2004
I'm trying to combine results from two tables into a single query. I'm
using MySQL 4max. The two tables are
Hits
Time
Domain
Clicks
Time
Domain
I can pull up a list of counted Hits and a list of counted Clicks, but I
want to put them in a single query linked by Domain like:
Domain Hits Clicks
somedomain.com 256 108
Seems like I'm not thinking the SQL through or perhaps don't have enough
experience to do it this way. I could write it into a program, but a
single SQL statement would be much better.
what i just tried:
SELECT Domain, count(*) as Hits,
select count(Clicks) as Clicks from Clicks where Hits.Domain =
Clicks.Domain
FROM `Hits`
GROUP BY Domain
Order by Hits DESC
More information about the talk
mailing list