Hi

Could you explain this a little more.
Never used LEFT JOIN before, only get error when trying it.

Could you specify the query more detailed ?

Thanks for your help 

Best regards

Tom


----- Original Message ----- 
From: Paul Chamberlain <[EMAIL PROTECTED]>
To: FreeTrade <[EMAIL PROTECTED]>
Sent: Wednesday, July 12, 2000 12:49 AM
Subject: Re: [FreeTrade] Listing orders with status


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



------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Site:            http://www.working-dogs.com/freetrade/
Problems?:       [EMAIL PROTECTED]

Reply via email to