Hi All

I have the following situation:

the DB has three tables 'users', 'links' and 'searches'. Each table has a
common key named 'userid'

What I want to do is, for each user in the 'lguser' table I'd like to count
the number of corresponding records in EACH of the 'lghyperlink' and
'lgsearch' tables.

I have the following query which counts the number of records in
`lghypoerlink` for each record in `lguser` but I can't figure out how to
incorporate the `lgsearch` table and count the rows.

SELECT u . username , count( l.username )  AS clicks
FROM  `lguser`  AS u
LEFT  JOIN  `lghyperlink`  AS l ON u.username = l.username
GROUP  BY u.username
ORDER  BY clicks DESC

I'm trying for output like:

username | clicks | searches
============================
test     |   12   |   45
anon     |   20   |   23


Any help or suggestions would be much appreciated

regards,

Bill Stennett




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to