[Zope] Z PyGresql DA questions

Rob Page rob.page@digicool.com
Wed, 21 Jul 1999 23:05:28 -0400


> Hi. I'm building a loan system with Zap and I have a SQl statement   
> problem. Let's say I have 2 table:  loan and  doc
> 
> Fields in doc:    pno *
>                    doctype *
>   docloc
>   ...
> 
> Fields in loan: usrid *
>       pno *
>   doctype *
>   ...
> Note: * means primary key
> 
> What I want to query is how do I get all the pno and its 
> according type,   
> that doesn't exist in the loan table? This is to make sure that the   
> borrower does not select a document that had been loaned!!! 
> In other   
> words, all documents except those that are being borrowed.

How 'bout:

SELECT * from doc WHERE pno NOT IN (SELECT pno FROM loan)

--Rob