Count Distinct itesm from mySQL query

Attempting to get distinct count value back of the number "threads" in a query

SELECT COUNT( ft.thread_id ) AS num_items
FROM filter_thread ft
INNER JOIN filter f ON ft.filter_id = f.filter_id
WHERE f.tag LIKE  '%foo%'
OR f.tag LIKE  '%bar%'

The above works, but due to the way the tables are set up, counts duplicates. I've tried adding DISTINCT in many places. but had no luck.

For more information...this information is required to correctly list page numbers and associated posts for an AJAX comment section

Answers


Try this

SELECT COUNT( ft.thread_id ) AS num_items
FROM filter_thread ft
INNER JOIN filter f ON ft.filter_id = f.filter_id
WHERE f.tag LIKE  '%foo%'
OR f.tag LIKE  '%bar%'
GROUP BY ft.thread_id

Need Your Help

Testing private void method using jmockit

java jmockit

I have a private void method of a class .I want to test it using the Jmockit ,is there a Way ?

How to merge two images in opencv?

visual-c++ image-processing opencv computer-vision image-stitching

I have calculated homography ,taken out perspective transform .I am able two display two images in one window but unable to merge them.Here are my example images->