Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Anders Altberg
 To: bryan wetton
  Where is bryan wetton?
 Morphett Vale
 bryan wetton
Subject: RE: SQL Help
Thread ID: 228861 Message ID: 228879 # Views: 1 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Friday, May 22, 2009 12:01:25 PM         

> I have a problem with an SQL statement - I know that what I have done (using the plain list of tables )is not correct as I get more than one copy of certain records. I need help to JOIN correctly. Can someone suggest the modifications to this code below the FROM statement( I have tried but cannot get it right).
> Select A.&myflagfield As flagval,;
> G.Edate,;
> G.Recno As MyRecno,;
> G.EFoot As Myextra,;
> G.Etype As ETYPENUM,;
> G.placenum As placenum,;
> A.ref_id As tmg_ID,;
> A.dsid As dsid,;
> T.etypename As etypename;
> FROM ;
> where T.ETYPENUM= G.Etype;
> and N.Nper=G.per1;
> and N.primary;
> and A.per_no=N.Nper;
> AND A.ref_id > 0;
> Into Table mycursor1
> Thanks
> -Bryan

If you get more rows than expected it's because there are duplicate of the key fields, or because there's a correct 1:M reletionship between two tables and a legitimate case of two rows in the referencing table, like two order lines for an order id.
Stop duplication by using arimary Key or Candidate index on columns where you can't allow duplicates.


SQL Help Posted by bryan wetton @ 5/22/2009 9:11:07 AM
RE: SQL Help Posted by Christian Tabligan @ 5/22/2009 10:27:11 AM
RE: SQL Help Posted by bryan wetton @ 5/22/2009 11:59:29 AM
RE: SQL Help Posted by Christian Tabligan @ 5/25/2009 1:40:05 AM
RE: SQL Help Posted by Anders Altberg @ 5/22/2009 12:01:25 PM