Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 To: chandu sekhar
  Where is chandu sekhar?
 miami
 Florida - United States
 chandu sekhar
 Tags
Subject: RE: foxpro query
Thread ID: 233064 Message ID: 233071 # Views: 33 # Ratings: 1
Version: Visual FoxPro 9 Category: ODBC, ADO and OLEDB
Date: Monday, June 29, 2009 7:29:47 PM         
   


> 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)



COMPLETE THREAD
foxpro query Posted by chandu sekhar @ 6/29/2009 6:45:59 PM
RE: foxpro query Posted by Borislav Borissov @ 6/29/2009 7:08:31 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 7:20:17 PM
RE: foxpro query Posted by Borislav Borissov @ 6/29/2009 7:25:19 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 7:55:11 PM
RE: foxpro query Posted by Anders Altberg @ 6/29/2009 8:48:51 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 8:07:04 PM
RE: foxpro query Posted by Cetin Basoz @ 6/29/2009 7:29:47 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 7:58:13 PM
RE: foxpro query Posted by Anders Altberg @ 6/29/2009 8:10:12 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 8:40:33 PM
RE: foxpro query Posted by Anders Altberg @ 6/29/2009 8:52:10 PM
RE: foxpro query Posted by chandu sekhar @ 6/29/2009 9:08:24 PM
RE: foxpro query Posted by Anders Altberg @ 6/29/2009 11:00:07 PM
RE: foxpro query Posted by chandu sekhar @ 6/30/2009 4:12:31 PM
RE: foxpro query Posted by Anders Altberg @ 6/30/2009 4:41:10 PM