Re: SQL Problem
Posted in 1998
Topics: SQL Development & Query Writing
Thanks to all who took the time to help me. My problem was one of
perception - I was seeing the conditions in the WHERE clause as operating on
the complete set created by the joins rather than being integral in the
joining process. In other words...I shouldn't have placed a condition on a
table in an outer join, because that merely prevents the particular columns
in that table appearing in particular result set rows... as opposed to
preventing those row as a whole appearing. (If you know what I mean! :0)
I hence solved the problem by using a sub-query instead thus:
SELECT order.order_no, orderdetail.line_no, ordernotes.text,orderdetailnotes.text
FROM orders, orderdetails, OUTER ordernottes, OUTER orderdetailnotes
WHERE order.order_no = orderdetail.order_no AND
order.order_no = ordernotes.order_no AND
ordernotes.order_no = orderdetailnotes.order_no AND
orderdetail.line_no = orderdetailnotes.line_no AND
order.order_no IN (SELECT DISTINCT order_no FROM ordernotes)
ORDER BY order.order_no, orderdetail.line_no
Thanks again.
--
Mel Mullen ( mel.mullen@mail.com )