Hi:
As a general observaton I'd say addresses cause more coding trouble than any other piece of data...here's my current issue.
I have an address table which can contain up to 5 addresses per customer. The address table has a location field (1 = mailing, 2 = street, etc.
I want to select the 2nd (street) address or the 1st (mailing) if no street address exists, or return null if there are no adddresses.
The code I have so far is:
SELECT distinct addr.cardrecordid, addr.location, cus.name, ;
streetline1 as delivery1,;
FROM customers as cus;
LEFT OUTER JOIN address as addr ON addr.cardrecordid= cus.cardrecordid ;
where addr.location <=2 OR addr.location is null ;
GROUP BY addr.cardrecordid;
INTO CURSOR tmpaddr readwrite
From the resulting table, this *looks* like it will work, but will it? It's the join using <= that I'm not sure about - what's the guarantee of getting the 2nd adddress if they both exist?
Regards
Mike
As a general observaton I'd say addresses cause more coding trouble than any other piece of data...here's my current issue.
I have an address table which can contain up to 5 addresses per customer. The address table has a location field (1 = mailing, 2 = street, etc.
I want to select the 2nd (street) address or the 1st (mailing) if no street address exists, or return null if there are no adddresses.
The code I have so far is:
SELECT distinct addr.cardrecordid, addr.location, cus.name, ;
streetline1 as delivery1,;
FROM customers as cus;
LEFT OUTER JOIN address as addr ON addr.cardrecordid= cus.cardrecordid ;
where addr.location <=2 OR addr.location is null ;
GROUP BY addr.cardrecordid;
INTO CURSOR tmpaddr readwrite
From the resulting table, this *looks* like it will work, but will it? It's the join using <= that I'm not sure about - what's the guarantee of getting the 2nd adddress if they both exist?
Regards
Mike