mysql outfile how more records then the count

43 Views Asked by At

this is probably a crazy question but I am curious if anyone else has seen this. I have a database with 150 fields and 717002 records in it. If I do a count on business type like this:

SELECT COUNT(*) FROM contractors WHERE BusinessTypeString LIKE '%A5%';

I get 60898 records which is fine. But when I write out a statement to add in the headers and write it to an outfile I get 60604 which is 294 records less. No errors Below is the statement I used.

SELECT
  'BusinessName', 'DbaName', 'PhysicalAddressLine1', 'PhysicalAddressLine2', 
  'PhysicalAddressCity', 'PhysicalAddressProvinceOrState', 'PhysicalAddressZipPostalCode', 
  'PhysicalAddressZipCodePlus4', 'PhysicalAddressCountryCode', 'CorporateUrl', 
  '1stBusPocFirstName', '1stBusPocMiddleInitial', '1stBusPocLastName', '1stBusPocUsPhone', 
  '1stBusPocUsPhoneExt', '1stBusPocEmail'
UNION
(SELECT
  BusinessName, DbaName, PhysicalAddressLine1, PhysicalAddressLine2,
  PhysicalAddressCity, PhysicalAddressProvinceOrState, PhysicalAddressZipPostalCode, 
  PhysicalAddressZipCodePlus4, PhysicalAddressCountryCode, CorporateUrl, 
  1 stBusPocFirstName, 1 stBusPocMiddleInitial, 1 stBusPocLastName, 1 stBusPocUsPhone, 
  1 stBusPocUsPhoneExt, 1 stBusPocEmail 
  INTO OUTFILE '/home/VOB_Full.csv' FIELDS TERMINATED BY ',' 
  OPTIONALLY ENCLOSED BY '"'
FROM contractors
WHERE BusinessTypeString LIKE '%A5%');

Any ideas?

0

There are 0 best solutions below