3 example queries:
This is all about the difference between the 2nd example and the 3rd example.
The 1st example returns one record.
The 2nd example returns 1 record.
The 3rd example does not return any records.
The only difference between the 2nd and 3rd examples is the 2nd expression in the last iif is a subquery. Because the 1st expression in that iif is false, the subquery should not get executed. Obviously it is somehow effecting the results but how/why?
Code:
SELECT Pl_dscs.cid;
FROM itfwarehouse!pl_dscs;
INNER JOIN itfwarehouse!nonbaggedsys_descs ON Pl_dscs.cnonbaggedsys_descs_id = nonbaggedsys_descs.cid;
WHERE PL_dscs.cnonbaggedsys_descs_id = lcnbsdcid AND;
iif(.f.,pl_dscs.ldiscontinued=.f.,.t.) AND;
iif(.f.,.t.,.t.) INTO CURSOR lcresult
SELECT Pl_dscs.cid;
FROM itfwarehouse!pl_dscs;
INNER JOIN itfwarehouse!nonbaggedsys_descs ON Pl_dscs.cnonbaggedsys_descs_id = nonbaggedsys_descs.cid;
WHERE PL_dscs.cnonbaggedsys_descs_id = lcnbsdcid AND;
iif(.f.,pl_dscs.ldiscontinued=.f.,.t.) AND;
iif(.f.,.f.,.t.) INTO CURSOR lcresult
SELECT Pl_dscs.cid;
FROM itfwarehouse!pl_dscs;
INNER JOIN itfwarehouse!nonbaggedsys_descs ON Pl_dscs.cnonbaggedsys_descs_id = nonbaggedsys_descs.cid;
WHERE PL_dscs.cnonbaggedsys_descs_id = lcnbsdcid AND;
iif(.f.,pl_dscs.ldiscontinued=.f.,.t.) AND;
iif(.f.,NOT pl_dscs.cid in (select cpl_dscs_id FROM itfwarehouse!pl_dscsperfacwsite WHERE pl_dscsperfacwsite.cfacilities_id = ""),.t.) INTO CURSOR lcresult
This is all about the difference between the 2nd example and the 3rd example.
The 1st example returns one record.
The 2nd example returns 1 record.
The 3rd example does not return any records.
The only difference between the 2nd and 3rd examples is the 2nd expression in the last iif is a subquery. Because the 1st expression in that iif is false, the subquery should not get executed. Obviously it is somehow effecting the results but how/why?