Access to the db engine is often interrupted by mixing INNER and LEFT inputs. If this request works without the last internal connection ...
SELECT * FROM (((orders INNER JOIN orders_customers ON orders.CUST_ORDER_ID = orders_customers.ID) LEFT JOIN quoted_theory ON orders.PART_ID = quoted_theory.PART_ID) LEFT JOIN conversions ON orders.PART_ID = conversions.PART_ID) LEFT JOIN dbo_WO_Header ON orders.CUST_ORDER_ID = dbo_WO_Header.PPC_Number
... then you can try this part as a subquery and inner lines_qry for the subquery. This may result in an error.
SELECT * FROM ( SELECT * FROM (((orders INNER JOIN orders_customers ON orders.CUST_ORDER_ID = orders_customers.ID) LEFT JOIN quoted_theory ON orders.PART_ID = quoted_theory.PART_ID) LEFT JOIN conversions ON orders.PART_ID = conversions.PART_ID) LEFT JOIN dbo_WO_Header ON orders.CUST_ORDER_ID = dbo_WO_Header.PPC_Number ) AS sub INNER JOIN lines_qry ON sub.CUST_ORDER_ID = lines_qry.WORKORDER_BASE_ID
If any table other than orders includes a field named CUST_ORDER_ID , you need something other than SELECT * in the subquery to avoid ambiguity.
source share