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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:18:16+00:00 2026-05-13T21:18:16+00:00

I am working on an auction web application. Now i have a table with

  • 0

I am working on an auction web application. Now i have a table with bids, and from this table i want to select the last 10 bids per auction.

Now I know I can get the last bid by using something like:

SELECT bids.id FROM bids WHERE * GROUP BY bids.id ORDER BY bids.created

Now I have read that setting an amount for the GROUP BY results is not an easy thing to do, actually I have found no easy solution, if there is i would like to hear that.

But i have come up with some solutions to tackle this problem, but I am not sure if i am doing this well.

Alternative

The first thing is creating a new table, calling this bids_history. In this table i store a string of the last items.

example:

bids_history
================================================================
auction_id   bid_id     bidders               times
    1        20,25,40   user1,user2,user1     time1,time2,time3

I have to store the names and the times too, because I have found no easy way of taking the string used in bid_id(20,25,40), and just using this in a join.
This way i can just just join on auction id, and i have the latest result.

Now when there is placed a new bid, these are the steps:

  • insert bid into bids get the lastinserteid
  • get the bids_history string for this
    auction product

    • explode the string
    • insert new values
    • check if there are more than 3
    • implode the array, and insert the string again

This all seems to me not a very well solution.
I really don’t know which way to go. Please keep in mind this is a website with a lot of bidding’s, they can g up to 15.000 bidding’s per auction item. Maybe because of this amount is GROUPING and ORDERING not a good way to go. Please correct me if I am wrong.

After the auction is over i do clean up the bids table, removing all the bids, and store them in a separate table.

Can someone please help me tackle this problem!

And if you have been, thanks for reading..

EDIT

The tables i use are:

bids
======================
id      (prim_key)
aid     (auction id)
uid     (user id)
cbid    (current bid)
created (time created)
======================

auction_products
====================
id        (prim_key)
pid       (product id)
closetime (time the auction closses)

What i want as the result of the query:

result
===============================================
auction_products.id   bids.uid   bids.created
2                        6         time1
2                        8         time2
2                        10        time3
5                        3         time1
5                        4         time2
5                        9         time3
7                        3         time1
7                        2         time2
7                        1         time3

So that is per auction the latest bids, to choose by number, 3 or 10

  • 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-13T21:18:16+00:00Added an answer on May 13, 2026 at 9:18 pm

    Using user variable, and control flow, i end up with that (just replace the <=3 with <=10 if you want the ten auctions) :

    SELECT a.*
    FROM
     (SELECT aid, uid, created FROM bids ORDER BY aid, created DESC) a,
     (SELECT @prev:=-1, @count:=1) b
    WHERE
     CASE WHEN @prev<>a.aid THEN
       CASE WHEN @prev:=a.aid THEN
        @count:=1
       END
     ELSE
       @count:=@count+1
     END <= 3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 324k
  • Answers 324k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can write one pretty easily, but you'll want to… May 14, 2026 at 1:22 am
  • Editorial Team
    Editorial Team added an answer I noticed that the same happens in my Emacs. The… May 14, 2026 at 1:22 am
  • Editorial Team
    Editorial Team added an answer If you intend to always return an empty enumerable then… May 14, 2026 at 1:22 am

Related Questions

The environment of my application: web-based, Spring MVC+Security, Hibernate, MySQL(InnoDB) I am working on
I am creating my own custom T4 Template that integrates with an ADO.NET Entity
On a recent project I have been working on in C#/ASP.NET I have some
Now that RC1 is out I need to decide once and for all whether
We are in the process of re-evaluating our usage of JSF (brought in before

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.