I am coding something to get all duplicate term which has duplicate name using MySql query. The issue I have currently is I am getting the records in a single occurrence I need all data which has same name.
I am running this query.
SELECT a.*,COUNT(name) AS occurrences
FROM wp_terms AS a
INNER JOIN wp_term_taxonomy AS b ON a.term_id = b.term_id
WHERE b.taxonomy = "ticker"
GROUP BY a.name HAVING occurrences > 1
Current result
[0] => stdClass Object
(
[term_id] => 13872
[name] => AAV
[slug] => aav
[term_group] => 0
[occurrences] => 2
)
Expected result
[0] => stdClass Object
(
[term_id] => 13872
[name] => AAV
[slug] => aav
[term_group] => 0
[occurrences] => 2
)
[1] => stdClass Object
(
[term_id] => 13873
[name] => AAV
[slug] => aav-2
[term_group] => 0
[occurrences] => 2
)
Any ideas on that?
Post a Comment