I am trying to select distinct but its not working
SELECT Distinct `table1`.`myID` AS `myID`,
`table1`.`TypeID` AS `TypeID`,
Is there any thing I am missing?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Distinct doesn’t work on a single field, it works on the entire row. Your result contains only the distinct rows, i.e. only rows where all fields are the same are removed.
If you want distinct values for a specific field, you can use
group by:This will give you a result with distinct values for
myID, but for the fields that you are not grouping on you should specify which value to get. For this you use aggregates likeminandmax. MySQL might allow you specify fields without aggregates, but then it will just pick the first value that comes up (which might not at all be what you think would be the first value).