Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: SQL
Divers
Thread ID:
00414860
Message ID:
00414887
Vues:
20
You used SQL Server (ANSI) standard for join conditions (ie select ... from table1, table2 WHERE ), that is always work as INNER JOIN. This means when appropriate record does not exist for one of tables, row will not be included into query result.
To run query by way you want, use native VFP join conditions, like in sample below:

select orders.id, iif(isnull(clients.name),"Sir/Madam",clients.name) as name ;
from orders ;
LEFT JOIN clients ;
ON orders.id == clients.order_id ;
into cursor temp

When you have more than 1 client record for 1 order record (that is not real :), VFP will select as many records as you have clients for one order.

------------------------------------------------
What did I do wrong in the following statement it returns no record:
select orders.id, iif(isnull
(clients.name), "Sir/Madam",clients.name) as name ;
from orders,clients ;
where orders.id == clients.order_id ;
into cursor temp
what I am trying to do is if the order has a contact name I will print out the name otherwise just say "sir/madam". thanks.
sherry
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform