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

  • Home
  • SEARCH
  • 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 6137683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:45:27+00:00 2026-05-23T17:45:27+00:00

This might be confusing but what I want to do is a basic select

  • 0

This might be confusing but what I want to do is a basic select distinct columnx limit 3, the problem I have is it returns 3 rows, but I only want to get all values from one distinct columnx.

id|columnx  
1 |here  
2 |here  
3 |Idontwant  
4 |Apple

so I want a query that will return 1 and 2. The problem is columnx could be anything and I cant just say where columnx = ‘here’

The limit 3 comes into play because it’s hard coded into my C# app. The issue is i also set a hashset based on columnx, i have to have that columnx static for all records. However, with every query i put together there is the possibility that with my limit i’ll return 2 values in columnx, which are distinct values however, i can only have distinct columnx value per query.

No what I want is all values that belong to columnx, in this example columnx =’here’, when i do a distinct all I want back is the first distinct result, not ‘Idontwant’ or ‘apple’ regardless of the limit.

Here is the query and it works.

SELECT id,columnx
FROM sites where columnx= (select distinct columnx from sites limit 1) limit 3
  • 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-23T17:45:28+00:00Added an answer on May 23, 2026 at 5:45 pm

    It sounds like you want the id values for three distinct columnx values. Is this right? Try this:

    SELECT id, columnx
    FROM table AS t1
    JOIN (
        SELECT DISTINCT(columnx) AS columnx
        LIMIT 1
    ) AS t2 ON (t1.columnx = t2.columnx);
    

    I also wonder if you need some ORDER BY in there somewhere, but your question doesn’t mention that, so I’ve omitted it–essentially meaning that you’ll get three semi-random columnx values.

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

Sidebar

Related Questions

The title of this question might be confusing but the problem is simple. I'm
Alright, I might make this confusing, but hopefully not. So I have a UITableView
Ok this might be a bit confusing, but here goes. Let's say I have
This is a very basic concept, but something I have never been able to
Okay so the title might sound a bit confusing, but here's what I want
This might be a silly question, but I want to ask if there is
This might be a silly question, but: Suppose an expression depends only on literals,
OK, this might sound a bit confusing and complicated, so bear with me. We've
This one might be a little confusing. I'm using AMCharts with rails. Amcharts comes
This might seem like a stupid question I admit. But I'm in a small

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.