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 774471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:08:16+00:00 2026-05-14T19:08:16+00:00

I have a query: SELECT Content.content_name, Language2.Name, Language2.language_id, Content.id, Content.content_description, FROM Language AS Language2

  • 0

I have a query:

SELECT Content.content_name, Language2.Name, Language2.language_id, 
Content.id, Content.content_description, 
FROM Language AS Language2 
LEFT JOIN contents AS Content ON (Language2.language_id = Content.language_id) 

How do I select only the distinct content_name?

  • 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-14T19:08:16+00:00Added an answer on May 14, 2026 at 7:08 pm

    You do this:

    SELECT DISTINCT Content.content_name
    FROM Language AS Language2 
    LEFT JOIN contents AS Content ON (Language2.language_id = Content.language_id)
    

    So why does this not answer your question?

    Let’s consider the following data (just the first two columns):

    content_name      Name
     XXXXX            1234
     XXXXX            5678
    

    SELECT DISTINCT implies you only want one row, but what do you want for Name?

    What you need to do is rewrite the code to use GROUP BY and pick the appropriate aggregate function for the other columns:

    SELECT
        Content.content_name,
        MIN(Language2.Name) AS Name,
        MIN(Language2.language_id) AS language_id, 
        MIN(Content.id) AS id,
        MIN(Content.content_description) AS content_description, 
    FROM
        Language AS Language2 
        LEFT JOIN contents AS Content
            ON (Language2.language_id = Content.language_id) 
    GROUP BY
        Content.content_name
    

    Now, likely this does not produce what you want either, but one thing is for certain, you can not trick the database engine to just “pick one of the rows to return, I don’t care which one.”

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

Sidebar

Related Questions

I have a following SQL QUERY: SELECT articles.name, articles.price, users.zipcode FROM articles INNER JOIN
I have this query: SELECT page.id, revision.title, revision.number FROM page INNER JOIN revision ON
I have the following query: SELECT c.* FROM companies AS c JOIN users AS
I have the following query: select column_name, count(column_name) from table group by column_name having
I have this SQL query: SELECT * FROM IMAGES WHERE IMAGENAME in ('IMG1', 'IMG2',
If I have a query like: Select EmployeeId From Employee Where EmployeeTypeId IN (1,2,3)
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE
I have the following SQL query: select expr1, operator, expr2, count(*) as c from
I have the following (shortened query): SELECT `Statistics`.`StatisticID`, COUNT(DISTINCT `Flags`.`FlagType`) AS `FlagCount` FROM `Statistics`
I have a select query that currently produces the following results: Description Code Price

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.