Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL
Message
De
11/09/2000 10:33:11
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: SQL
Divers
Thread ID:
00414860
Message ID:
00414882
Vues:
19
Hi Sherry,

Depending on your business logic, either this is the wrong statement or you're using the wrong function.

In your code, ISNULL will never fire because you are doing a left INNER join an there will never be a NULL value returned for clients.name. If there is no matching clients row, the orders row won't be put into the result set. Now if you want orders with no matching record in clients and to use "Sir/Madam" for nulls, (which sounds likely in your case), then use this code (also note the change in the AS {name} clause). Also note the SPACE(n)...replace n with the difference between the field length of clients.name and the length of "Sir/Madam".

SELECT orders.id,;
IIF(ISNULL(clients.name),"Sir/Madam"+SPACE(n),clients.name) AS cname ;
FROM orders ;
LEFT OUTER JOIN clients ;
ON orders.id = clients.order_id ;
INTO CURSOR temp


>HELLO,
> 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
------------------------------------------------
John Koziol, ex-MVP, ex-MS, ex-FoxTeam. Just call me "X"
"When the going gets weird, the weird turn pro" - Hunter Thompson (Gonzo) RIP 2/19/05
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform