List:General Discussion« Previous MessageNext Message »
From:Baron Schwartz Date:January 31 2009 3:51pm
Subject:Re: UPDATE ... where max(datecolumn)
View as plain text  
Is there ever more than one order per day?

I also think you might mean "most current order per product", but you
didn't say that.

On Tue, Jan 27, 2009 at 8:38 AM, Adria Stembridge
<adrya.stembridge@stripped> wrote:
> I have a table like this:
>
> ID   PRODUCT  DATEORDERED
> 1    5                2005-02-18
> 2    2                2008-03-13
> 3    2                2008-11-21
> 4    6                2009-01-21
>
> A field has been added for current order to this table:
>
> ID   PRODUCT  DATEORDERED FLAGCURRENT
>
> I need to update all records in the table (about 400,000) so that the most
> current order has FLAGCURRENT=1 (else 0).   Is there an optimal way of doing
> this with a single query?
>



-- 
Baron Schwartz, Director of Consulting, Percona Inc.
Our Blog: http://www.mysqlperformanceblog.com/
Our Services: http://www.percona.com/services.html
Thread
UPDATE ... where max(datecolumn)Adria Stembridge27 Jan
  • Re: UPDATE ... where max(datecolumn)Baron Schwartz31 Jan