> Hello Friends,
>
> I have a table that as two fields "Productcode" & "Needlecode".
> This has many to many relationship.
> What I means is:
>
> A single productcode can have lot of needlecodes.
> A single needlecode can have lot of productcodes.
>
> What I need to generate is a report that should have by productcode with all respective needlecodes.
> I have been thinking to write a query regarding that.
> But i am not getting perfect thinking.I am totally clueless.
> Please help me.
> I will be so thankful to you.
>
> Thanks & Regards,
> Chandra0315.
VFP sample file Orders constitute a similar many-to-many as in your sample. It has emp_id and cust_id in it, meaning a Customer could be served by many employees (salesman) and a salesman can serve multiple customers.
* all customer, salesman combinations
select distinct cust_id, emp_id from (_samples+'data\orders')
* all customer, salesman combinations with some data from Customer table
select distinct customer.cust_id, customer.Company, customer.Contact, emp_id ;
from (_samples+'data\orders') ;
inner join (_samples+'data\customer') ;
on customer.cust_id = orders.cust_id
* all customer, salesman combinations with some data from Customer and Employee table
select distinct cs.cust_id, cs.Company, cs.Contact, em.emp_id,em.First_name, em.last_name ;
from (_samples+'data\orders') o ;
inner join (_samples+'data\customer') cs on cs.cust_id = o.cust_id ;
inner join (_samples+'data\employee') em on em.emp_id = o.emp_id
You can apply these patterns to your tables.
Cetin Basoz
.Net has got better.Think about moving - check my blog:
Blog (main)Blog (mirror)