This is the way things work
I personally use Wordpress category tables and also have 2 primary groups. The first is known as "location" and also the other one "subject". Both groups have sub groups that belongs to them.

During my example we've "location" category 17 and "subject" category 3.

This is exactly what I wish to do
I wish to choose Just the data where BOTH my groups 17 And Three are presented.

This code works to date

SELECT term_id, post_title, post_name, ID, object_id, post_status
FROM wp_posts AS wpost
INNER JOIN wp_term_relationships
   ON wpost.ID = wp_term_relationships.object_id

INNER JOIN wp_term_taxonomy
   ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id AND wp_term_taxonomy.taxonomy = 'category'

WHERE wp_term_taxonomy.term_id IN (17, 3)
   AND post_status = 'publish'

The issue
Both groups 17 and three is available within the same column. The code above lists the IDs two times when the posts apears both in groups.

It is possible to method to count the IDs which are equal within the result? If ID is available two times, choose the publish from that ID.

This can choose each publish only one time, whether it is available both in groups:

SELECT  post_title, post_name, post_status
FROM    wp_posts AS wpost
WHERE   post_status = 'publish'
        AND EXISTS (
        SELECT   1
        FROM     wp_term_relationships
        INNER JOIN
                 wp_term_taxonomy
        ON       wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
                 AND wp_term_taxonomy.taxonomy = 'category'
                 AND wp_term_taxonomy.term_id IN (17, 3)
        WHERE    wp_term_relationships.object_id = wpost.ID
        LIMIT 1, 1
        )

This could get it done (provided you will find no duplicate rows to have an entry finding yourself in category 3 or 17) without resorting to a nested query:

SELECT term_id, post_title, post_name, ID, object_id, post_status, COUNT(*) as count
FROM wp_posts AS wpost
INNER JOIN wp_term_relationships
   ON wpost.ID = wp_term_relationships.object_id

INNER JOIN wp_term_taxonomy
   ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id AND wp_term_taxonomy.taxonomy = 'category'

WHERE wp_term_taxonomy.term_id IN (17, 3)
   AND post_status = 'publish'
   AND count = 2

GROUP BY ID

Adding the count variable and the GROUP BY clause will clump replicates together. After this you filter for rows where count equals 2 to obtain the records both in groups.

A measure closer? The only factor I have to do is really a way show the rows that consists of "2" within the column "count".

Since the count column is produced inside the "loop" it did not try to just write "AND count = 2".

This situation shows the end result such as the count column:

SELECT term_id, post_title, post_name, ID, object_id, post_status, COUNT(ID) as count
FROM wp_posts AS wpost
INNER JOIN wp_term_relationships
   ON wpost.ID = wp_term_relationships.object_id

INNER JOIN wp_term_taxonomy
   ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id AND wp_term_taxonomy.taxonomy = 'category'

WHERE wp_term_taxonomy.term_id IN (17, 3)
   AND post_status = 'publish'

GROUP BY ID