Sunday, 8 September 2013

Mysql count and count distinct in same query

Mysql count and count distinct in same query

I have the following 2 tables:
user_table:
user_id
job_id
job_link
job_table:
job_id
click_ip
click_date
I have to count clicks both distinct and all clicks for each job for the
current user. Can anybody tell me if this is possible with current table
structure and have an answer to this. Thanks.
My current query is also tried with inner join:
SELECT `user_id` , job.job_id AS job_id, `job_link`,
COUNT( job.click_ip ) AS click_ip
FROM `job` , `user`
WHERE job.job_id = user.job_id
AND user.user_id =7
GROUP BY job_id

No comments:

Post a Comment