SELECT * FROM myTable ORDER BY COLUMN_WHICH_CONTAINS_INSERTED_DATE ASC LIMIT 1; COLUMN_WHICH_CONTAINS_INSERTED_DATE is a column which contains the date that the record was inserted Hth, Martin ----- Original Message ----- From: "Mateusz" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, June 01, 2003 7:17 PM Subject: Re: SELECTing last occurences from a table
> That'd be the solution, but unfortunately i gave You incorrect example (too > little rows): > the problem is I don't have a constant number of foods. For example the > latest price of tomatoes could be from day 20 but the last price of potatoes > might be from day 19, and for onions from day 1. I need single most recent > row for each type of food that has appeared in database. > > ----- Original Message ----- > From: "Becoming Digital" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, June 02, 2003 12:28 AM > Subject: Re: SELECTing last occurences from a table > > > > Do you have daily prices for a set number number of foods? If so, try > > > > SELECT * FROM food > > LIMIT n,-1; > > > > where n is the number of items. There's probably a better way to do it in > SQL, > > I just don't know how. If you are using PHP, that's another story. > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]