I have, SELECT DISTINCT (first),second,third FROM table
AND i want not only the first to be DISTINCT and the second to be DISTINCT to but the third to stay without DISTINCT , i tryed like that.
SELECT DISTINCT (first,second),third FROM table
And couple more things but didnt worked.
SELECT  m.first, m.second, m.third -- and possibly other columns
FROM    (
        SELECT  DISTINCT  first, second
        FROM    mytable
        ) md
JOIN    mytable m
ON      m.id =
        (
        SELECT  id
        FROM    mytable mi
        WHERE   mi.first = md.first
                AND mi.second = md.second
        ORDER BY
                mi.first, mi.second, mi.third
        LIMIT 1
        )
Create an index on (first, second, third) for this to work fast.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With