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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:38:20+00:00 2026-05-26T09:38:20+00:00

Here is my query: SELECT * FROM Photos WHERE Event_ID IN ($eventidstring) I know

  • 0

Here is my query:

SELECT * FROM Photos WHERE Event_ID IN ($eventidstring)

I know I can limit the total amount of results from this query using LIMIT 5

I need the Limit the amount of results Per value in $eventidstring.

So if $eventidstring = 23,41,23*

*And there are 10 results WHERE Event_ID = 23, I want to limit this amount to 5. The same for all the other values in $eventidstring.

  • 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-26T09:38:21+00:00Added an answer on May 26, 2026 at 9:38 am

    You may have some joy doing something similar to Oracle’s RANK by PARITION in MySQL.

    Sadly this feature is not available in MySQL though you can work around it using this method

    Dump that in an inline view and then select those rows with rank <= 5;

    Hence:

    SELECT t.* FROM (
    SELECT ( 
            CASE Event_id 
            WHEN @curEventId 
            THEN @curRow := @curRow + 1 
            ELSE @curRow := 1 AND @curEventId := Event_Id END
          ) AS rank,
          p.*
    FROM      Photos p INNER JOIN (SELECT @curRow := 0, @curEventId := '') r
    ORDER BY p.Event_Id DESC
    ) t
    WHERE t.rank <= 5 ORDER BY t.Event_Id asc;
    

    Consider how you are going to ‘choose’ the top five by Event_Id too. You can always add in more after the ORDER BY p.Event_Id DESC to decide this.

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

Sidebar

Related Questions

Here is my query Select Gender from Table The result pane shows 1 1
Here is my Query : select EmployeeName, EmployeeSalary from Employee2 for xml path('EmployeeDetails') returns
So here is the original query SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID FROM PickRequest GROUP
Here is the pseudo-code for my inline query in my code: select columnOne from
Here is the query that I am working on: SELECT `unitid`, `name` FROM apartmentunits
Here is my LINQ query: (from o in entities.MyTable orderby o.MyColumn select o.MyColumn).Distinct(); Here
We have a Union Query. Here's a basic (similar) example: SELECT a.Name, b.Info FROM
So firstly here's my query: ( NOTE:I know SELECT * is bad practice I
Here's my query: SELECT * FROM designs AS d LEFT JOIN categories AS c
Here's my query: SELECT * FROM daily_records AND date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)

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.