[NBLUG/talk] SQL statement
Augie Schwer
augie at schwer.us
Thu Aug 19 13:43:59 PDT 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Walter Hansen said:
> 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
Is this what you want?
select hits.domain,clicks.count as clicks,hits.count as hits
from hits,clicks
where hits.domain = clicks.domain;
Augie.
- --
registered linux user #229905
gpg public key: http://www.schwer.us/schwer.asc
Key fingerprint = 9815 AE19 AFD1 1FE7 5DEE 2AC3 CB99 2784 27B0 C072
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBJREHy5knhCewwHIRAmI9AKCShPjSdpHjO76qZ8n77MBovRuo0wCeJqAN
ikZ/c8DEY5tvQ/3PbKHNlAE=
=V763
-----END PGP SIGNATURE-----
More information about the talk
mailing list