Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question about using select
Message
De
19/07/2004 22:20:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
19/07/2004 22:15:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00925999
Message ID:
00926004
Vues:
18
This message has been marked as the solution to the initial question of the thread.
>select a.callno, a.reservee, b.callno, b.borrower from reserve a, borrower b where a.callno=b.callno
>
>how can i use SELECT-SQL to select all records from table reserve even if it does not satisfy the WHERE condition? but display b.borrower when a.callno=b.callno.
>
>pls help.

Use the JOIN option instead of WHERE.

You can use the query builder to help you, at least to get the initial code.

Your code above would be equivalent to:
select a.callno, a.reservee, b.callno, b.borrower;
  from reserve a join borrower b on a.callno=b.callno
Just changing JOIN to LEFT JOIN will include all records from the left table (reserve in this case):
select a.callno, a.reservee, b.callno, b.borrower;
  from reserve a left join borrower b on a.callno=b.callno
Fields from table "b" will be NULL if there is no matching record. You can solve this with nvl(), for instance:
select a.callno, a.reservee, nvl(b.callno, 00000), nvl(b.borrower, space(30);
  from reserve a left join borrower b on a.callno=b.callno
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform