* Alec Smith > I've got a database along the lines of the following > > ---------------- -------------- ---------------- > | Transactions | | Products | | TransDetails | > ---------------- -------------- ---------------- > | TransID | | ProdID | | TransID | > | TransDate | | ProdName | | ProdID | > | ..... | | .... | | ..... | > ---------------- -------------- ---------------- > > (I have replaced a bunch of other fields with .... for briefity) > > What I need to be able to do is get a list of all products not having a > transaction since a certain date, but am not having much luck. Anyone out > there willing to offer save my day?
What about something like this: SELECT P.* FROM Products P LEFT JOIN TransDetails TD ON TD.ProdID = P.ProdID LEFT JOIN Transactions T ON T.TransID = TD.TransID AND T.TransDate > '$SelectedDate' WHERE ISNULL(T.TransID) The idea is to join the rows you do NOT want, i.e. rows with transactions after the selected date, and then only return the results where such transactions was NOT found, i.e. TransID is NULL because of the left join. -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]