How to improve this query to delete the duplicates after performing group by in mysql
===

I have the following query which query all the entries that share the same parent domain name (Ex: aaa.msn.com, bbb.msn.com. fff.msn.com), grouping them by key value. My requirement is that: If the entries share the same domain name, I need the key value to be saved once only. So, I need to delete the duplicate entries and their key values that share the same parent domain name.

Here is my current query. My question: How can I delete the duplicate values ? and when I make group by, based on which criteria MySQL return the values. Ex: The query return to me domainname, which one SQL chose? The first one alphabetically or what ? 

    SELECT table1.domainname, 
    table2.keyvalue
    FROM db.table1
    INNER JOIN db.table2
    ON table1.domainname=table2.domainname
    WHERE table1.domainname like '%msn.com' Group by table2.keyvalue ORDER BY
    table1.domainname;

I have a lot of such cases, so I need practical solution.