I've a table with the following data
id parent_id ascii_name lang
1 123 Foo en
2 123 Foo fi
3 456 Bar it
4 345 Foo fr
I want to select all the records that have the same parent_id
and ascii_name
, basically I want this:
id parent_id ascii_name lang
1 123 Foo en
2 123 Foo fi
Right now I was able to select the records having only the same ascii_name
:
id parent_id ascii_name lang
1 123 Foo en
2 123 Foo fi
4 345 Foo fr
using the query:
SELECT * FROM table WHERE ascii_name in
(SELECT ascii_name FROM table GROUP By ascii_name
HAVING "count"(ascii_name) > 1)
I don't know how to put the parent_id
into the equation.
Update
I found the right query using both @jakub and @mucio answers:
SELECT * FROM geo_nodes_copy WHERE (parent_id,ascii_name) in
(SELECT parent_id, ascii_name
FROM geo_nodes_copy
GROUP By parent_id, ascii_name
HAVING count (1) > 1)
Now, the only problem is, maybe, the query speed.