Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excluding NULL values in an SQL query
Message
 
 
À
05/04/2002 06:02:02
Denis Filer
University of Oxford
Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00640805
Message ID:
00641345
Vues:
21
>Cetin/Sergey, When my new joined table is created based on a main table 1 and a second table 2 (that may have either 1 or no records in it related to table 1), the Select function adds NULLs to the new file when the table 2 records are missing. Ideally, I would like to have empty fields of the same type in file 2. I suspect this is rather basic stuff! Denis

It isn't as simple as it looks. AFAIK, only VFP has empty dates, for example. That's why there's no option or clause in SELECT statement to force replacement of nulls with empty values. However, there is NVL() function in VFP or ISNUL() function in SQL Server that allows to convert Null on field by field basis to any value you want including empty one, if it's supported by particular DBMS. So if you want your query to return empty values for Nulls in the second table than wrap each field from the second table into NVL function.
Select t1.*, ;
    NVL(t2.n_fld1, 0), NVL(c_fld2, ""), NVL(d_fld3, {}), ... ;
  FROM table1 t1 LEFT JOIN table2 t2 ON ...
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform