I am trying to send a "UNION" SQL statement from Crystal Reports through ODBC to some VFP tables. The statements seem to work fine independently but when I try to UNION them using a Crystal command I lose records. Below is the statement:
SELECT
`sllines`.`item` as item,
`sllines`.`needby` as needby,
`sllines`.`orderqty` as oqty,
`sllines`.`shipqty` as sqty,
`imlocn`.`locid` as locid,
`slheader`.`ordrstat` as orderstat,
`sllines`.`linestat` as linestat
FROM (`slheader` `slheader` INNER JOIN `sllines` `sllines` ON (`slheader`.`docid`=`sllines`.`docid`) AND (`slheader`.`doctype`=`sllines`.`doctype`)) LEFT OUTER JOIN `imlocn``imlocn` ON `sllines`.`item`=`imlocn`.`item`
WHERE (`slheader`.`ordrstat`='A' OR `slheader`.`ordrstat`='P')
UNION ALL
SELECT
`wo`.`partno` as item,
`wo`.`need_date` as needby,
`wo`.`exp_4` as oqty,
`wo`.`exp_5` as sqty,
'wo' as locid,
'wo' as orderstat,
'wo' as linestat
FROM `wo` `wo`
The first SELECT, when run alone returns 181 records. The second SELECT, when run alone returns 3 records. When combined they return 150 recoords from the first select and none from the second. This works as expected in MS Access but not in VFP. Not sure what I am missing here.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides for Formulas, Parameters, Subreports, VB, .NET, Tips and Tricks
SELECT
`sllines`.`item` as item,
`sllines`.`needby` as needby,
`sllines`.`orderqty` as oqty,
`sllines`.`shipqty` as sqty,
`imlocn`.`locid` as locid,
`slheader`.`ordrstat` as orderstat,
`sllines`.`linestat` as linestat
FROM (`slheader` `slheader` INNER JOIN `sllines` `sllines` ON (`slheader`.`docid`=`sllines`.`docid`) AND (`slheader`.`doctype`=`sllines`.`doctype`)) LEFT OUTER JOIN `imlocn``imlocn` ON `sllines`.`item`=`imlocn`.`item`
WHERE (`slheader`.`ordrstat`='A' OR `slheader`.`ordrstat`='P')
UNION ALL
SELECT
`wo`.`partno` as item,
`wo`.`need_date` as needby,
`wo`.`exp_4` as oqty,
`wo`.`exp_5` as sqty,
'wo' as locid,
'wo' as orderstat,
'wo' as linestat
FROM `wo` `wo`
The first SELECT, when run alone returns 181 records. The second SELECT, when run alone returns 3 records. When combined they return 150 recoords from the first select and none from the second. This works as expected in MS Access but not in VFP. Not sure what I am missing here.
Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides for Formulas, Parameters, Subreports, VB, .NET, Tips and Tricks