Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question about using select
Message
From
19/07/2004 22:20:54
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
19/07/2004 22:15:37
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00925999
Message ID:
00926004
Views:
19
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)
Previous
Reply
Map
View

Click here to load this message in the networking platform