Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL JOIN Problem
Message
De
21/02/2006 12:05:58
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01097776
Message ID:
01097779
Vues:
12
>I'm not sure why this isn't working. The 2nd and 3rd records in the result set have their
>captions returned as NULL.
>
>Here's the SQL
>
>select alh.id,;
>       alh.asset_id,;
>       alh.loc_id,;
>       v.internal_id,;
>       l.caption,;
>       alh.from_date,;
>       alh.to_date;
>  from asset_loc_hist alh;
>  left join vehicles v on v.id = alh.asset_id;
>  left join locations l on l.id = alh.loc_id;
>  where asset_id = 2 and ;
>	asset_type = 0;
>  into cursor temp1
>
>
>Here's the result set:
>
>ID    ASSET_ID      LOC_ID INTERNAL_ID    CAPTION         FROM_DATE  TO_DATE
> 1           2           3 F150-1         John Jackson    01/15/2005 03/23/2005
> 2           2          16 F150-1         .NULL.          04/18/2005 04/26/2005
> 3           2          11 F150-1         .NULL.          07/19/2005   /  /
>
>
>
>Here's the tables.
>
>
>Asset_Loc_Hist
>--------------------------------------------------------------
>ID    ASSET_ID      LOC_ID ASSET_TYPE  FROM_DATE    TO_DATE
> 1           2           3          0 01/15/2005 03/23/2005
> 2           2          16          0 04/18/2005 04/26/2005
> 3           2          11          0 07/19/2005   /  /
>
>
>
>Vehicles
>--------------------------------------------------------------
>ID   VENDOR_ID LOCATION_ID     TYPE_ID INTERNAL_ID
> 2           1           0           0      F150-1
> 3           1           0           0      F250-1
> 4           1           0           0      F150-2
>
>
>Locations
>--------------------------------------------------------------
>ID  LOC_CAT_ID EMPLOYEE_ID CAPTION
> 1           1           0 Main Office
> 2           2           0 F150-1  VIN 55557
> 3           3           2 John Jackson
>
l.id = alh.loc_id;
11 and 16 are not in locations as id.

HTH
Beth
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform