[NBLUG/talk] SQL statement

Steve Johnson gnuguy at gmail.com
Fri Aug 20 08:49:29 PDT 2004


Augie beat me to the responce =) But I thought I would add that what
this is called is a join. =)

-Steve


On Thu, 19 Aug 2004 12:19:28 -0700 (PDT), Walter Hansen
<gandalf at sonic.net> wrote:
> 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
> 
> _______________________________________________
> talk mailing list
> talk at nblug.org
> http://nblug.org/cgi-bin/mailman/listinfo/talk
> 


-- 
      "Knowing others is wisdom, knowing your self is Enlightenment."
                                                   -- Lao-Tzu
|C8H10N4O2|




More information about the talk mailing list