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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:11:48+00:00 2026-05-13T02:11:48+00:00

OK I have a column on my table called style_number. There can be duplicates

  • 0

OK I have a column on my table called style_number. There can be duplicates of style_number. I want to select everything, but only up to 3 for each style number.

So for example if there are 4 rows that have a style_number = “style 7” only 3 of those 4 would be selected (doesn’t matter which 3, any 3).

Does this make sense?

How can I do that?

Thanks!!

Note: I am using 4.1.22

EDIT:
To clear some confusion. I need all the other columns as well, and I need more than just “style 7” or I could easily limit to 3. but for example if this where my table:

style_number | price | stone_count

"style 7" | 300 | 2
"style 7" | 400 | 3
"style 7" | 500 | 4
"style 7" | 600 | 5
"style 8" | 200| 1
"style 8" | 300 | 2

I would get this as a result:

"style 7" | 300 | 2
"style 7" | 400 | 3
"style 7" | 500 | 4
"style 8" | 200| 1
"style 8" | 300 | 2

Does that make better sense?

  • 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-13T02:11:48+00:00Added an answer on May 13, 2026 at 2:11 am

    I’m not a MySQL developer, but I think that this will give you what you want. No promises on performance though 🙂

    SELECT
         T1.id,
         T1.style_number,
         T1.col1,
         T1.col2,
         ...
    FROM
         My_Table T1
    WHERE
         (
              SELECT
                   COUNT(*)
              FROM
                   My_Table T2
              WHERE
                   T2.style_number = T1.style_number AND
                   T2.id < T1.id
         ) < 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a table called Companies that has a DepartmentID column. There's also
I have a column in a MySQL table called year. I want to check
i have a table column called status - data type is boolean. i want
I have a table column called post_tags within a table called posts where assigned
MS SQL Server 2000 I have a column in Table A called Name. I
I have a table called Event. A column has duration--which is...how long that event
I have a table called ApprovalTasks... Approvals has a status column I also have
I have a table called scheduler_sched which has several columns, including a column called
I have a table called, tblClient with an encrypted column called SSN . Due
I have a nullable DateTime column in my SQL Server 2005 table called DateTimeDeleted.

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.