Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excluding NULL values in an SQL query
Message
From
05/04/2002 06:26:14
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
05/04/2002 06:02:02
Denis Filer
University of Oxford
United Kingdom
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00640805
Message ID:
00641294
Views:
18
>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

Denis,
IMHO just 'set nulldisplay' would be sufficient :

select ... into cursor crsMyCursor
set nulldisplay to ''
brow

If no and provided you really want blanks instead of nulls then blank the right table fields for null ones :
select * from customer ;
  left join orders on customer.cust_id = orders.cust_id ;
  into cursor myCursor nofilter
use dbf('myCursor') in 0 again alias 'myCursorRW'
use in 'myCursor'
select 'myCursorRW'
lcFields = ''
for ix=fcount('customer')+1 to fcount()
 lcFields = lcFields + iif(empty(lcFields),'',',')+field(ix)
endfor	
blank fields &lcFields for isnull(eval(field(fcount('customer')+1)))
brows
PS: Being null might be realted for really right table had a null, better use FKId :

select *, orders.cust_id as FKID ...
..
blank fields &lcFields for isnull(FKID)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform