Support » Plugins and Hacks » Get all object_id's where term_taxonomy_id is IN(1,2) AND NO IN(3)

  • Ralac

    (@ralac)


    Hello,

    how can i get all object_id’s from the wp_term_relationships where term_taxonomy_id is IN(1,2) AND NOT IN(3)

    Means…

    object_id	term_taxonomy_id	term_order
    1		1			0
    1		2			0
    1		3			0
    2		1			0
    2		2			0
    3		1			0
    3		2			0
    4		1			0
    5		1			0
    5		3			0

    I need the get object_id 2 and 3

    SELECT c1.object_id
    FROM wp_term_relationships AS c1
    INNER JOIN wp_term_relationships AS c2 ON c1.object_id = c2.object_id
    WHERE c1.term_taxonomy_id = 1
    AND c2.term_taxonomy_id = 2

    Works, but i don’t know how to exclude term_taxonomy_id 3

    Thanks!

  • The topic ‘Get all object_id's where term_taxonomy_id is IN(1,2) AND NO IN(3)’ is closed to new replies.