Tom Jakobsen wrote:
> Any1 knows how to query the database to only
> list orders that has order status 1 as its last status.
Not exactly, but I've come up with a creative way to say
that it has a status 1 but not a status 2. Maybe you can
dream up some way to get what you want....
SELECT i.ID
FROM invoice i
LEFT JOIN status s1 ON s1.Invoice=i.ID AND s1.Status=1
LEFT JOIN status s2 ON s2.Invoice=i.ID AND s2.Status=2
WHERE s1.Status=1
AND s2.Status IS NULL
By using table aliases you can join with the same table
twice and by using LEFT JOIN it fills in a field of NULLS
if there is no matching record.
(this is off the top of my head cuz I have to leave now,
but I've done something very much like this before.)
--
Paul Chamberlain, [EMAIL PROTECTED]
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Site: http://www.working-dogs.com/freetrade/
Problems?: [EMAIL PROTECTED]