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.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


----- Original Message -----
From: "Mateusz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, 01 June, 2003 15:38
Subject: SELECTing last occurences from a table


Hi!
I couldn't find anything in archives, maybe I search for wrong phrase.
I'm running MySQL v.3.23.49 (if it's not possible under this version, I may
upgrade it).
What I need to accomplish is to find only last occurence of all possible
items from given column.

Supposing:

id    name        day    price
---------------------------
1    tomatoes        1    25
2    onions        1    13
3    onions        2    16
4    tomatoes        2    30

I want to obtain only:

3    onions        2    16        (latest price of onions - from day 2nd)
4    tomatoes    2    30        (latest price of tomatoes - from day 2nd)

How to do that? (in as little selects as possible)
Thanks for any help!

Mateusz Uzdowski


--
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]

Reply via email to