Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 902461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:43:14+00:00 2026-05-15T15:43:14+00:00

I am trying to select distinct but its not working SELECT Distinct `table1`.`myID` AS

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:43:14+00:00Added an answer on May 15, 2026 at 3:43 pm

    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:

    select table1.myID, min(table1.TypeID) as TypeId
    from ...
    group by table1.myID
    

    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 like min and max. 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).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Was trying to select...into a temp Table #TempTable in sp_Executedsql. Not its successfully inserted
I'm trying to select distinct substring values of a field and count the number
So I'm running MySQL version 5.1.4 and I'm trying to select distinct by a
I am trying to execute the following Query select distinct pincode as Pincode,CAST(Date_val as
I'm trying to perform a DISTINCT clause on a query like this SELECT DISTINCT
Im trying to replicate the following sql in Nhibernate ICriteria SELECT DISTINCT AP.ID FROM
In trying to select elements that have any attributes, the following throws a jQuery
When trying to select fields from a subquery if ANY of the subqueries do
I'm trying to select cpu_time from the db, but the time must correspond with
I am trying to select of the duplicate rows in mysql table it's working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.