On 6/12/06, Peter Lauri <[EMAIL PROTECTED]> wrote:
--------------------------

Here's what it looks like right now:

SELECT * FROM products p
INNER JOIN manufactors m ON m.manufactor_id = p.manufactor_id
INNER JOIN items i ON i.product_id = p.product_id

The problem is, that each entry in "products" may occur more than once
in "items", and they are identified by "product_id" in both tables.
How do I filter out the results from the last INNER JOIN by certain
criterias? I want the INNER JOIN to only return the row from items
which has the lowest value in the column "item_updated".

--------------------------

Just add:

ORDER BY i.item_updated GROUP BY i.product_id

(assuming that item_updated and product_id are in table i)

That gives me the result that I'm after, the only problem seems to be
that the sorting is
made before the matching - on all the rows (huge execution time) - how
can I prevent this?

MVH
--
Kim Christensen

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to