Im sure this is nothing new but I have tried all kind of joins and am very frustrated why my one to many relationship is gettin screwed up during my query. Heres my scenario:
I have 3 tables, Orders which are a 1 to many link by 'wo' to Orderlines and Clients which link to Orders by 'client_no'. I previously query my Orderline table to create a report by product code into cursor 'c_order_lines' I then need to query the table Orders to search for the accompanying records with the main order details for each order_line. When I do this my unique orders are duplicated within the cursor c_orders dependent upon how many order_lines there are thus messing up my report
Heres the code im using:
select orders.prefix, ;
orders.wo, ;
client.business, ;
orders.custno, ;
orders.location, ;
orders.accep_date, ;
orders.enqno ;
from client, orders right outer join c_order_lines ;
on orders.wo == c_order_lines.wo ;
where orders.client_no == client.client_no ;
order by client.business ;
into cursor c_orders
I have 3 tables, Orders which are a 1 to many link by 'wo' to Orderlines and Clients which link to Orders by 'client_no'. I previously query my Orderline table to create a report by product code into cursor 'c_order_lines' I then need to query the table Orders to search for the accompanying records with the main order details for each order_line. When I do this my unique orders are duplicated within the cursor c_orders dependent upon how many order_lines there are thus messing up my report
Heres the code im using:
select orders.prefix, ;
orders.wo, ;
client.business, ;
orders.custno, ;
orders.location, ;
orders.accep_date, ;
orders.enqno ;
from client, orders right outer join c_order_lines ;
on orders.wo == c_order_lines.wo ;
where orders.client_no == client.client_no ;
order by client.business ;
into cursor c_orders